Phase 4: Dynamic Programming¶
M6 – M7.5 | Weeks 24–30 | Jan 12 – Feb 22, 2027
Most people quit DP not because it’s impossible, but because they try to memorize 200 solutions instead of recognizing the 7 underlying patterns. Every DP problem you will ever encounter is a variant of one of those 7 patterns. Learn the patterns. The solutions follow automatically.
The correct mental model for DP is this: “Can I express the answer to a bigger problem in terms of answers to smaller subproblems — and do those subproblems repeat?” If yes, you have a DP problem. The skill is recognizing which of the 7 structural forms it takes, then designing the state and transition correctly. State design is the hard part. Everything else is mechanical.
This phase has the highest attrition of the entire roadmap — not because DP is harder than graphs or trees, but because the feedback loop is brutal. You either see it or you don’t, and beginners often spend two weeks grinding without a framework and make no progress. This guide is that framework.
The 7 DP Patterns¶
Pattern |
Canonical Problem |
Key State Design Insight |
|---|---|---|
1D Linear |
House Robber, Coin Change |
|
2D Grid |
Unique Paths, Edit Distance |
|
Knapsack |
0/1 Knapsack, Partition Equal Subset Sum |
|
Interval |
Burst Balloons, Matrix Chain Multiplication |
|
Subsequence |
LIS, LCS, Edit Distance |
State tracks position in one or two sequences |
Tree DP |
House Robber III, Tree Diameter |
DP on tree nodes, computed bottom-up via DFS |
Bitmask DP |
Traveling Salesman, Task Assignment |
|
Why This Phase Has the Highest Attrition¶
Three reasons people fail here, in order of lethality:
Wrong entry point. They start with LeetCode Hard problems before understanding overlapping subproblems. Start with foundations, not problems.
Memorizing instead of deriving. You can memorize the coin change solution in 10 minutes and still be unable to solve a novel problem 2 months later. Derive every recurrence from scratch.
Skipping state design. The state is not the problem — it’s the decision. Most DP bugs are incorrect state definitions, not coding errors.
Phase Files¶
File |
Topic |
Difficulty |
|---|---|---|
Overlapping subproblems, memoization, tabulation, state design |
Foundation |
|
Fibonacci, House Robber, Coin Change, Jump Game |
Easy–Medium |
|
Grid paths, Edit Distance, LCS |
Medium |
|
0/1, Unbounded, Bounded, Subset Sum |
Medium–Hard |
|
Burst Balloons, LIS, Palindrome DP |
Hard |
|
Tree DP, TSP via bitmask |
Hard |
|
The meta-skill: pattern taxonomy + recognition |
Meta |
|
What “done” looks like + 3 projects |
Deliverables |
Recommended External Resources¶
NeetCode DP playlist (YouTube, free) — best video explanations of state transitions
TakeUForward (Striver’s DP series) (YouTube, free) — exhaustive, builds intuition
cp-algorithms.com — reference for interval DP, bitmask DP, tree DP
LeetCode Explore Card: Dynamic Programming (free) — structured problem set with editorial hints
Navigation ← Phase 3: Graphs & Trees | Phase Overview | Next: DP Foundations →