Advance two pointers along the linked list.
- Pointer A moves one node at a time.
- Pointer B moves two nodes at a time.
If there's no cycle, pointer A can never catch up to pointer B.
If there is a cycle, pointer A and pointer B will eventually land on the same node.
something-something something
link to a Gist or Github