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

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

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.