Given the head of a singly linked list, return the middle node of the linked list. If there are two middle nodes, return the second middle node.
Example 1
Input: head = [1,2,3,4,5]
Output: [3,4,5]
Explanation: The list has 5 nodes, so the middle is the 3rd node, 3. Returning it gives the rest of the list from there: [3,4,5].
Example 2
Input: head = [1,2,3,4,5,6]
Output: [4,5,6]
Explanation: The list has 6 nodes, so there are two middles, 3 and 4. We return the second one, giving [4,5,6].
Example 3
Input: head = [1]
Output: [1]
Explanation: The only node is the middle.
Advance a slow pointer one step and a fast pointer two steps. When fast reaches the end, slow sits at the middle.
Run checks all cases above. Submit evaluates all test cases.