Level 3 · Structures
Free Backtracking lessons
8 lessons, about 69 minutes in all. Each teaches one idea with a visual, then gives you one problem built for it. Read the lessons here, then create a free account to solve the problems and keep your progress.
Stage 0Build, check, undo
- Generate binary stringsMake a choice, explore the consequences, and backtrack to try the other choice.8 min
- Generate all subsetsFor each item, decide whether to include it or exclude it, backtracking each time.9 min
- Generate valid parenthesesPrune impossible branches by only adding closing brackets when open brackets outnumber them.9 min
- Root-to-leaf path sumExplore downward paths, subtracting values along the way, and backtrack when a branch fails.8 min
Stage 1Combinations
- Combinations of size kPick numbers moving forward only, so every combination shows up exactly once.8 min
- Combination sum, each number onceReuse the forward-only walk from combine, but stop on a running total instead of a fixed size.9 min
- Letter combinations of a phone numberInstead of two choices per step, loop over a whole group of letters — one digit, one position.8 min
- Combination sum, numbers can repeatRecurse from the same index instead of the next one, so a number can be chosen more than once.10 min
There’s more after this
These are the opening stages of Backtracking. The full path climbs on to harder problems and a mastery test. Create a free account and we’ll keep your place.
Start the full path free