01 · Question
Given the head of a linked list, return the middle node. If there are two middle nodes, return the second one.
02 · Solution
1def middleNode(head: Optional[ListNode]) -> Optional[ListNode]:2 slow = head3 fast = head4 while fast and fast.next:5 slow = slow.next6 fast = fast.next.next7 return slow