Floyd · detect and locate
A slow and a fast pointer meet if a linked list cycles. Reset one to the head and move both one step to locate the entrance.
Remember: Meet first; reset one; walk together.
Example: 10 → 20 → 30 → 20 has cycle entrance 20.
Time: O(n). Auxiliary space: O(1).
Formula: slow moves 1; fast moves 2
Tail links to the selected zero-based node index; −1 means no cycle. Collision is not necessarily the entrance.
Complexities describe the underlying algorithm; tutorial snapshots and rendering can use additional resources.
The interactive workspace loads here when JavaScript is available. You can still browse the learning notes and links above without it.