Floyd's Tortoise and Hare: two pointers at different speeds collide if and only if a cycle exists.
Detect whether a singly linked list contains a cycle using two pointers moving at different speeds. The slow pointer (tortoise) advances one node per step while the fast pointer (hare) advances two. If a cycle exists they are guaranteed to meet inside it; otherwise the fast pointer falls off the end of the list.
Start slow and fast at the head. On each iteration, slow moves one step and fast moves two steps. The relative speed difference is exactly 1 node per iteration. That difference drives the whole algorithm.
Once both pointers enter the cycle, the gap between them shrinks by exactly one node every iteration (fast gains one on slow). Since the cycle is finite, that gap will hit zero (slow and fast land on the same node) in at most C iterations, where C is the cycle length.
If there is no cycle, the fast pointer will reach the end of the list first. The loop guard `while fast and fast.next` catches this. Once either is null, we exit and return False. This is the only way the algorithm can conclude "no cycle".
Turn on "Find the start" to run the second phase (LeetCode 142). After they meet, slow goes back to the head and fast stays at the meeting point; now both move one node at a time. The distance from the head to the cycle entry equals the distance from the meeting point to the entry going round the loop, so they meet again exactly at the entry.
Time is O(n): slow visits each node at most once before the pointers meet (or fast exits). Space is O(1): only the two pointers are stored regardless of list size, which is the key advantage over the hash-set approach.
Floyd's cycle detection is also the foundation of Brent's algorithm, the cycle-detection trick in Tortoise-and-Hare integer factorization, and the standard solution to LeetCode 141 (Linked List Cycle) and 142 (find the cycle's entrance).