Quant Memo
Coding/●●●●●

Find the middle of a linked list in one pass

You receive the head of a singly linked list whose length you do not know in advance. You cannot walk it, count, then walk again cheaply if it is a huge on-disk list, and you may only traverse forward.

1 -> 2 -> 3 -> 4 -> 5      middle is 3
1 -> 2 -> 3 -> 4           middle is 3 (return the second of the two)

Return the middle node in one pass using O(1)O(1) extra space.

Your answer

This one is open-ended. Work it through, then check your reasoning against the full solution.

More Coding questions