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

Lessons

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

Practice it after

Real interview questions that test this pattern, in an editor with execution and AI feedback.