Two Pointers
Two indices, one pass: cut the pair-checking search space without missing an answer.
5 lessons · ~47 min · free
By the end you can
- Understand the elimination argument that lets two pointers skip most pairs safely
- Solve sorted pair-sum problems in one pass
- Rewrite arrays in place with a reader and a writer pointer
- Detect cycles with the fast and slow pointer trick
- Tell two-pointer problems apart from sliding window problems
Lessons
Start the course- A million pairs you never check8 minThe n² pair problem, and how sorted order lets two indices rule out almost all of it.
- Converging from both ends11 minPair sum on a sorted array, why moving the right pointer is always safe, and container-with-water.
- Reader and writer10 minSame-direction pointers that rewrite an array in place: dedupe, move zeroes, partition.
- Fast and slow pointers10 minFloyd's cycle detection: why a 2x pointer must lap a 1x pointer inside a loop.
- Spotting two-pointer problems8 minSorted input, in-place edits, pairs and palindromes: the cues, the traps, and the templates.
The account is free and so is every lesson. It unlocks the courses and saves your progress.
Practice it after
The final lesson links here too: real interview questions that test this pattern, in an editor with execution and AI feedback.