Problem. Given the head of a singly linked list, return the middle node. With an even number of nodes, return the second of the two middle nodes.
1 → 2 → 3 → 4 → 5 → node 3
1 → 2 → 3 → 4 → 5 → 6 → node 4 (the second middle)
The difficulty: a linked list doesn't know its length, and you can't jump to position n/2. The technique you learn here, two pointers moving at different speeds, solves a whole family of problems (lessons 7.4 and 7.6).
ML context. "Find the middle without knowing the length" is the linked-list version of a streaming question: data arrives once, you don't know how much there is, and you can't store it all. The streaming twin, picking a uniformly random item from a stream of unknown length, is reservoir sampling, used to sample training examples or log lines from a stream in one pass (Change D).