AlgoScope

Fast and Slow Pointers

TechniqueintermediateTwo Pointers

One pointer moves twice as fast as the other. Finds middles and cycles in one pass.

Decision · step 2 of 5Fast and Slow Pointers: Find the middle of seven
1✓234567headslowfast

Step 1: slow moves to 2, fast jumps two to 3.

Open in the player →or start at step 2

What you will see

The fast pointer laps the slow one in a cycle, or reaches the end when the slow one is halfway.

How fast and slow pointers works →

Cost

BestO(n)
AverageO(n)
WorstO(n)
SpaceO(1)

How you work with it here

play it through, step one change at a time, scrub to any step, run it on your own input, predict what happens next.

Screen readers: Pointers announce their name and index; each step announces which pointer moved and why.

Reduced motion: Pointers appear at their new index with a brief emphasis instead of gliding.

Taught by the same lesson

Fast and Slow Pointers covers these too, in the same run.