DSA Master › Topic 10

Recursion & Backtracking

Backtracking is a DFS over a tree of decisions. At each level you choose an option, recurse, then undo the choice. Draw the recursion tree first. Once you can see it, the code mostly writes itself.

Concepts

How to recognise it

Common pitfalls

Problems

  1. Subsets (Medium)
  2. Subsets II (Medium)
  3. Permutations (Medium)
  4. Combination Sum (Medium)
  5. Combination Sum II (Medium)
  6. Letter Combinations of a Phone Number (Medium)
  7. Palindrome Partitioning (Medium)
  8. N-Queens (Hard)
  9. Word Search (Medium)