Recursion & Backtracking problems, grouped by pattern

Backtracking explores every choice, undoes it, and tries the next. Learn the pick / not-pick tree once and subsets, combinations, permutations, N-Queens and word search become variations on the same template.

When to reach for it

  • Generate all subsets, combinations or permutations
  • Place items on a board under constraints
  • The answer is a list of all valid configurations

Mistakes to watch for

  • Adding the shared path list instead of a copy
  • Skipping duplicates at every depth instead of among siblings
  • Not restoring state after the recursive call

The 17 problems

1Basic Recursion

22D Matrix

3Pick / Not-Pick

4Permutations

52D Matrix Backtracking