Linked List Cycle

Linked lists · Fast and slow pointers · Easy · about 20 min

Why it matters

Fast/slow pointers solve several linked-list and sequence problems without extra memory.

How it connects

Pointers can build a list; two pointers moving at different speeds can also reveal a cycle.

Try first

If two runners enter a circular track, can the faster runner avoid the slower one forever?

Interview cue

The runners must meet inside a cycle, giving O(1) extra-space detection.