Backtracking

Try it, undo it, try the next thing: exhaustive search that cleans up after itself.

5 lessons · ~50 min · free

By the end you can

Lessons

  1. 1Every choice is a branch9 minSubsets as include-or-exclude decisions, and the tree that every backtracking problem walks.
  2. 2Choose, explore, unchoose11 minThe three-beat template, and why forgetting the undo corrupts every path after the first.
  3. 3Permutations and combinations11 minOne skeleton, two bookkeeping choices: a used-set when order matters, a start index when it doesn't.
  4. 4Cutting branches early11 minCombination sum with sorting and early exits: the same tree, a fraction of the visits.
  5. 5Spotting backtracking problems8 min"All possible" cues, the constraint sizes that whisper exponential, and backtracking vs DP.

Practice it after

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