Loading...
Loading...
Loading...
Print the value of the middle node of a linked list using slow and fast pointers. If the list has two middle nodes, print the second one.
Example 1
Input
1 2 3 4 5
Output
3
Example 2
Input
1 2 3 4
Output
3
Try the problem first. Open one hint at a time.
Move slow one node and fast two nodes at a time.
Loop while fast and fast.next.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor