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

Lessons

  1. 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. 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. 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

Module quiz

1. What should you decide first in a DP solution?
2. Why can greedy fail for coin change?
3. How many subsets does a set of 5 items have?
4. Why save a copy of the path when a backtracking solution is complete?
5. An LRU cache must find and move a key in O(1). Which structure fits in Python?
6. In a behavioural answer using STAR, what does the R stand for?

‹ Graphs, heaps and intervalsFinal assessment ›