Backtracking — NeetCode 250
This is a fresh, pattern-first study track for 15 core Backtracking problems. Read the foundation once, then work the problems in order. The aim is to recognize the decision tree before writing code.
Start here
- 00 - Backtracking Foundations
- 01 - Subsets and Duplicates
- 02 - Combinations and Targets
- 03 - Permutations
- 04 - Strings and Grids
- 05 - Constraint Search
The 15-problem track
How to use each problem note
Before looking at the solution, answer these five prompts aloud:
- What does one DFS call mean?
- What is the next decision?
- Which state is shared and must be undone?
- When is a partial path impossible?
- What condition means the answer is complete?
Then write the recurrence from memory. If you get stuck, compare the problem with its nearest neighbor in the same note—not with a memorized full solution.
One-page pattern map
| If the prompt says… | Reach for… |
|---|---|
| “every subset” | start index or include/exclude |
| “unique” and input has duplicates | sort, then skip equal choices at the same depth |
| “sum to target” | DFS with remaining target |
| “use a value again” | recurse with the same index |
| “use each value once” | recurse from the next index |
| “every ordering” | choose from unused values |
| “all valid cuts / strings” | try every next valid piece |
| “grid path cannot reuse a cell” | mark, explore, restore |
| “place / assign under rules” | choose a slot, maintain fast constraint sets, prune symmetry |
Why this guide covers 15 of NeetCode 250’s 17 Backtracking problems
NeetCode 250 currently labels 17 questions as Backtracking. This guide keeps the 15 where backtracking is the primary pattern to learn and solve.
The two exceptions are intentionally studied elsewhere:
- Partition to K Equal Sum Subsets — use the 1-D DP / bitmask-DP treatment. Although a brute-force search exists, the reusable interview pattern is state compression and memoization.
- Word Break II — use memoized DFS / 1-D DP after mastering ordinary backtracking. Its important idea is caching suffix results, not just exploring a decision tree.
Trie-led Word Search II is another worthwhile follow-on after this core track.