๐ข๐ฐ Fast & Slow Pointers โ Floyd's Cycle Detection
USACO C++ Book ยท Interactive Visualizer
๐ Floyd's Cycle Detection on a Linked List
Linked List
O(N) ยท O(1) space
Step 0/0
๐ Linked List
slow and fast start at head
๐ State
Phase 1: fast moves 2 steps, slow moves 1 step. If they meet โ cycle exists.
๐ป Code
Click Next Step to start
โ Prev
Next Step โถ
โบ Reset
0/0
Keyboard:
โ
Next
โ
Prev
R
Reset