Dynamic programming, backtracking and the mock interview
Solve each subproblem once with dynamic programming, enumerate solutions with backtracking, and put it all together in a full mock interview.
About 6 hours of study
Learning objectives
- Define a state and recurrence and fill a table
- Write choose, explore and un-choose with pruning
- Run a whole interview and design a small cache
Lessons
- 1
Dynamic programming patterns Intermediate
Spot a DP problem, define the state and the recurrence, and solve it top-down with memoization or bottom-up with a table: climbing stairs, house robber, coin change and the longest increasing subsequence.
- 2
Backtracking Intermediate
Build every solution one choice at a time and undo each choice afterwards: subsets, permutations, combination sum, and pruning branches that cannot succeed.
- 3
The mock interview Advanced
Put everything together: a complete solved problem narrated step by step, how to think out loud, how to test and recover from bugs, and what the behavioural and system-design rounds expect.
Module practice
- Climbing stairsEasy
- Coin changeMedium
- Longest increasing subsequenceHard
- All subsetsEasy
- Combination sumMedium
- N queensHard
- FizzBuzz warm-upEasy
- Longest consecutive runMedium
- Design an LRU cacheHard