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

  1. A million pairs you never check8 minThe n² pair problem, and how sorted order lets two indices rule out almost all of it.
  2. Converging from both ends11 minPair sum on a sorted array, why moving the right pointer is always safe, and container-with-water.
  3. Reader and writer10 minSame-direction pointers that rewrite an array in place: dedupe, move zeroes, partition.
  4. Fast and slow pointers10 minFloyd's cycle detection: why a 2x pointer must lap a 1x pointer inside a loop.
  5. 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.