Find the middle node in one pass, no length counting, no second pass.
Slow ๐ข moves one node at a time, fast ๐ moves two.
When fast runs out of road, slow is standing on the middle.
Execution
idle
Press Run to begin.
0 / 0
Speed
Java ยท running line
slow ๐ขfast ๐middle nodenull / end
O(n) time ยท O(1) space ยท for even-length lists this convention returns the
second middle โ the loop condition fast != null && fast.next != null is why.