🚀 Phases 1–5 are live — Days 1–17 cover the foundations and the algorithmic patterns. See the roadmap →
Day 16 - BacktrackingPractice QuestionsOverview

Backtracking Practice Questions

Ten interview classics, every template represented. Each one is a direct instance of one of the four canonical shapes, advanced patterns, or constraint-satisfaction puzzles — once you spot the shape, the code writes itself.

Before reading any solution, force yourself through the five-question checklist:

  1. What’s the partial solution? (Usually path + an index.)
  2. When is it complete? (Base case.)
  3. What are the candidate choices? (The loop body.)
  4. What’s the legality check? (Pruning — the highest-leverage optimization.)
  5. What’s the un-do? (The line after the recursive call.)

The code is a 10-line transcription of those five answers. If you can answer them, you’ve solved the problem.

Easy

ProblemPatternStatus
SubsetsThe subset templateAvailable
Letter Combinations of a Phone NumberFixed-depth, fixed-branching enumerationAvailable
Generate ParenthesesConstraint-baked candidate generatorAvailable

Medium

ProblemPatternStatus
PermutationsThe permutation template + used[] arrayAvailable
Combination SumUnbounded combinations with sort-and-pruneAvailable
Word SearchGrid DFS with in-place markingAvailable
Palindrome PartitioningString partition templateAvailable
Restore IP AddressesFixed-piece partition + validationAvailable

Hard

ProblemPatternStatus
N-QueensConstraint placement + incremental column/diag stateAvailable
Sudoku Solver3-way constraint propagation (row/col/box)Available

More Practice (Coming Soon)

ProblemPatternStatus
Subsets II (with duplicates)Subsets + duplicate-skip pruneComing Soon
Permutations II (with duplicates)Permutations + duplicate-skip pruneComing Soon
Combination Sum II / IIICombinations + sum constraintComing Soon
Word Search II (trie + DFS)Grid DFS over a Trie of wordsComing Soon
Word Break IIPartition + memoizationComing Soon
Unique Paths IIIGrid DFS visiting every walkable cellComing Soon
Partition to K Equal Sum SubsetsBitmask DP / backtracking with pruningComing Soon
Expression Add OperatorsInsert + - * between digitsComing Soon
Beautiful ArrangementPermutation with divisibility constraintComing Soon
Regular Expression MatchingConstraint matching with wildcardsComing Soon