Dynamic Programming Cheat Sheet
Cache each recursive call's result so an overlapping subproblem only gets solved once instead of over and over.

Earn the full sheet below.
When to reach for it
- Breaks into smaller, overlapping subproblems.
- Brute force recursion redoes the same work.
- Counts ways or min/max over a choice sequence.
What's on the sheet
Steps 1, 2, and 4 barely change. Step 3 is the whole problem, and 2D problems grow the memo to match.
- Base Case Check. Stops recursion at the simplest known values.
- Memoization Check. Solved before? Return the cached answer.
- Recurrence Relation. The recurrence IS the problem: how one answer builds from smaller ones.
- Memoization List Initialization. n+1 slots, all None.
Watch out
- Cache the result before you return it, not just when you compute it. Skip that and every call recomputes its whole subtree, right back to O(2^n).
- memo needs n+1 slots, not n. This off-by-one throws an index error the moment you ask for the top value.
- For a 2D memo, use [[None] * cols for i in range(rows)]. [[None] * cols] * rows duplicates one inner list across every row.
How to earn it
Solve half of the Dynamic Programming problems on InterviewCrunch and the sheet is yours. Free accounts included. Members can download every sheet right away.
Want to see a finished sheet first? Preview the Two Pointers sample.
Every pattern has a sheet. See the full set.