What you will learn
The four pillars of every DP solution: state, recurrence, base cases, and execution order
How to discover a state from the naive recursion using completeness, minimality, and enumerability
How to derive every recurrence from the Bellman optimality equation rather than memorise it
The four DP patterns: edit distance, subset sum, 2D grid, and prefix sum
Top-down memoisation versus bottom-up tabulation, and when each fits
The full knapsack family (0/1, unbounded, bounded, counting) and the canonical 2D string DPs
Why this course
Dynamic programming is the topic where most candidates lose Big Tech interviews, and the reason is rarely that the problem was hard. It is that almost every resource shows you a finished recurrence relation and asks you to memorise it, instead of teaching you how that recurrence got there. So you can recite the longest common subsequence recurrence in O(N*M) time, then have nothing to say the moment an interviewer rewrites the constraints.
This course teaches DP as a derivation pipeline. Four pillars: state, recurrence, base cases, and order of execution. You watch each one get discovered, verified, and assembled before any code is written. After that the course drills the four standard DP patterns and closes with a practice set where the pattern is left for you to identify, which is what interviews test.
Requirements
The course assumes you can write a recursive function and reason about its complexity. Prior pattern experience is welcome but not required.
- Comfort writing functions, loops, and recursive calls in at least one mainstream language.
- Familiarity with Big-O notation, especially O(N), O(N²), and O(N log N).
- A finished pass through the recursion course is recommended, since DP is recursion plus caching plus a chosen order.
Overview
Dynamic programming is the technique you reach for when a problem has overlapping subproblems and optimal substructure. The classics, longest common subsequence, edit distance, 0/1 knapsack, coin change, matrix chain multiplication, all share the same skeleton: define a state, write a recurrence, anchor the base cases, then pick an execution order that respects the dependency graph between states. Every DP problem is really a directed acyclic graph of states, and every solution is a walk over that graph.
Representation of dynamic programming
Once that skeleton is internalised, every new DP problem becomes a derivation exercise rather than a recall test.
Fundamentals
The course opens with the climbing stairs problem. You see how the naive recursion explodes to roughly O(φⁿ) because of overlapping subproblems, how memoisation collapses it to O(N), and why optimal substructure is the condition that makes any of this work. That single example anchors the rest of the course: it is the smallest problem where every pillar shows up, and you keep coming back to it as the patterns get heavier.
Then the four pillars are taught one at a time. State comes first, with three tests (completeness, minimality, enumerability) so you can tell a real state apart from a parameter that happens to vary. Recurrence comes next, derived in five steps from the Bellman optimality equation and verified with five checks before any code is written. Base cases are then split into genuine cases and boundary cases, with sentinel values chosen so they cannot accidentally win a min or max. Execution order closes the loop: top-down memoisation when the state space is sparse and recursion depth is safe, bottom-up tabulation when you need iterative control over space and order.
This four-pillar framework is the thing the rest of the course leans on. Every problem afterwards, from LIS to matrix chain multiplication to the knapsack family, is solved by walking through the same four steps in the same order, so the framework becomes muscle memory before you ever face an unseen problem.
Problem solving
After the foundations, the course turns to patterns. Four templates cover the vast majority of DP problems that appear in real interview loops.
Each pattern is taught in three layers. An Understanding lesson derives the recurrence on a canonical problem. An Identifying lesson teaches the signals that say a new problem fits the template. Then a set of problems lets you apply it. Around the four patterns the course also walks through a long sequence of canonical problems (longest increasing subsequence, longest common subsequence, longest palindromic subsequence, palindrome partitioning, all four knapsack variants, matrix chain multiplication, word break, rod cutting, coin change in three flavours), each solved end to end through the four-pillar framework. The course ends with a practice set of seven stand-alone problems where the pattern is deliberately not labelled, so you train the only skill that matters in an interview: recognising the shape of a problem you have not seen before.
How this course is different
Most DP material on the internet treats the recurrence as a given. This course treats it as the answer to a derivation you can do yourself.
Who this course is for
The course suits anyone who needs to derive DP solutions rather than recall them.
- New programmers who have written a recursive function but cannot tell when caching it would help.
- Self-taught and bootcamp graduates who can solve climbing stairs but stall the moment a problem has two state dimensions.
- Working developers who recognise a DP problem but cannot derive its recurrence from scratch in an interview.
- Engineers preparing for FAANG and Big Tech interviews where edit distance, knapsack, and 2D grid DP show up reliably in the harder rounds.
- Returning engineers who memorised a handful of DP solutions years ago and want a framework that survives a new problem.
- Anyone who has copied a DP solution from an editorial without understanding why the indices and base cases are arranged the way they are.
Continue your DSA journey
DP draws on several earlier topics and connects forward to several more. Pick the next course based on where your gaps are.
- Array: Every DP state table is a 1D or 2D array. The memory layout, row-major traversal order, and indexing arithmetic from the array course transfer directly to how you allocate, seed, and fill a DP table.
- Hash table: Prefix sum problems often pair a running sum with a hash table for O(N) complement lookups. The combination shows up constantly in subarray-sum and submatrix-sum interview questions.
- Graph: Many DP problems are shortest-path problems on the state-space DAG, and conversely Bellman-Ford and Floyd-Warshall are DP in disguise. The graph course makes the equivalence concrete.
- Recursion: DP is recursion plus caching plus a chosen execution order, so the recursion course is the substrate the entire DP framework sits on. If your recursive instincts are shaky, work through recursion before going deeper into DP.
- Backtracking: Backtracking is the alternative for optimisation problems that lack optimal substructure. Knowing which problems admit a DP solution and which require backtracking is half the skill of choosing the right approach.
- Searching: Some DP problems admit faster solutions when a binary search is layered on top, the canonical example being the patience-sorting variant of LIS that runs in O(N log N) instead of O(N²).