Return the middle node of the list. When the list has an even number of nodes there are two middle nodes: return the second one. The answer is the node together with all nodes after it.
The tests show a list as a Python list of its values: [1, 2, 3] stands for 1 -> 2 -> 3.
Example 1
Input:
middle_node(head) # head = 1 -> 2 -> 3 -> 4 -> 5
Output:
[3, 4, 5]
Example 2
Input:
middle_node(head) # head = 1 -> 2 -> 3 -> 4
Output:
[3, 4]
0 <= number of nodes <= 100000-10**9 <= val <= 10**9No results yet
Run your code to check it against the examples, or submit to run every test.