SLIDE 78: Section Intro, Dynamic Programming Patterns

Section 5: Dynamic Programming Patterns

Dynamic programming is the most feared topic in coding interviews, but it does not need to be. At its core, DP is backtracking with memory. In Section 4, we saw that backtracking explores a decision tree exhaustively. When that tree has overlapping subproblems (the same state is reached through different paths), backtracking wastes time recomputing the same answers. DP stores the result of each state the first time it is computed and reuses it for all future requests.

This single idea, caching results to avoid redundant computation, is what converts exponential backtracking into polynomial-time solutions. The skill is not memorizing solutions. It is learning to define the state, write the recurrence, and identify the base cases.

What We’ll Cover:

  1. What makes a problem a DP problem
  2. From recursion to memoization to tabulation
  3. 1D DP: Climbing Stairs, House Robber, Coin Change
  4. 2D DP: Unique Paths, Longest Common Subsequence
  5. Sequence DP: Longest Increasing Subsequence
  6. Knapsack-style DP
  7. The DP problem-solving framework
  8. Space optimization

Where This Appears in Interviews:

Company Type How This Section Appears
FAANG / Big Tech Coin Change, LCS, House Robber, and LIS are top-30 most-asked problems
Mid-size companies Climbing Stairs and Unique Paths appear in phone screens
Startups DP is less common but appears in optimization and string matching problems
Online assessments DP problems are common timed questions that separate strong candidates

Core Idea for This Section: DP applies when the problem has overlapping subproblems and optimal substructure. The skill is defining the state, writing the transition, and identifying the base cases.


SLIDE 79: What Makes a Problem a DP Problem

Two Required Properties: