Detect a cycle (tortoise and hare)
Two pointers, one twice as fast: if the list loops, the fast one catches the slow one.
List3, 1, 4, 1, 5, 9, 2loops to 2
Both pointers start at the head.
- compare
- swap or write
- settled
Space play · ← → step · Home End jump · drag the strip to scrub