Back to problems Solve on LeetCode → Next: Reverse Linked List →

Floyd's Cycle Detection Algorithm

Tortoise & Hare — Two-Pointer Technique

LeetCode 142 • Medium • Linked Lists

Time O(n) at most 2n steps
Space O(1) only 2 pointers
Steps: 0 Phase:
Slow (Tortoise) — 1 step
Fast (Hare) — 2 steps
Meeting Point
Cycle Start
Ready
Press Play to watch the algorithm run, or Step to advance one move at a time.
The linked list has 10 nodes with a cycle starting at node 3.