Learning order

1. Recursion

Premium

Take a deep dive into one of the most intuitive programming paradigm

Show Index

2. Backtracking

Premium

Learn about the ultimate recursive brute force technique

Show Index

3. Sorting

Premium

Learn all about algorithms to sort data blazingly fast

Show Index

4. Searching

Premium

Learn about the algorithms that speed up your searches exponentially

Show Index

5. Dynamic Programming

Premium

Learn the most powerful optimization for recursive problems

(Early Access)

Show Index

6. Bit Manipulation

Premium

Learn about the fastest ways to manipulate data

(Early Access)

Show Index

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.

The 4 dynamic programming patterns you'll master
Edit distance
Two indices walking two strings or sequences, branching on character match versus mismatch, with the recurrence shaped as the min or max of insert, delete, and replace alternatives in O(NM) time and O(NM) space. Wildcard Pattern Matching, Interleaving Check.
Subset sum
A choice over items with an include or exclude branch each step, parameterised by remaining target or capacity, the recurrence shape behind every knapsack variant in O(N*S) time. Partition With Equal Sum, Sets With Smallest Discrepancy.
2D grid
A two index state over the rows and columns of a matrix, with transitions to neighbouring cells and a recurrence shaped by which directions are legal, running in O(R*C) time. Longest Ascending Route, Largest Square Area, Destination Path Count, Largest Plus of 1's.
Prefix sum
Build a 1D or 2D prefix sum table in O(N) or O(R*C) preprocessing, then answer any range query in O(1) by subtracting four corners, the trick behind every submatrix sum question. K Limited Submatrix Sum, Maximum Submatrix Sum, Design a Range Sum Finder.

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.

Most DSA resources
This course
Hand you a finished recurrence relation and call it teaching.
Derives every recurrence from the Bellman optimality equation, so you can write a new one on the spot.
Treat memoisation as a one-line afterthought instead of a distinct execution order.
Treats the four pillars (state, recurrence, base cases, execution order) as separate steps with their own verification checks.
Skip the state space and jump straight to writing code.
Builds the state-space DAG mental model, so memoisation and tabulation become two views of the same graph.
Bundle every DP problem into one bucket without naming the underlying patterns.
Names the four standard patterns and teaches the identification signals before the solution.
Tell you the base cases instead of teaching how to identify and verify them.
Covers the full knapsack family (0/1, unbounded, bounded, counting) as one progression rather than four disconnected problems.

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²).

Frequently asked questions

Code examples use Python and C++ for readability, but the four-pillar framework (state, recurrence, base cases, execution order) is language-agnostic. The recurrences are derived as equations first, then translated to code, so you can follow the course in any language.
Yes, as long as you can write a recursive function. The course starts with the climbing stairs problem and shows how a naive recursion becomes a DP solution through memoisation, before introducing any of the heavier vocabulary.
There are around 64 lessons and 36 problems across the four pillars, four patterns, and the problem-led lessons in between. Most learners finish the lessons in 20 to 30 hours and need another 25 to 40 hours to solve the problems, depending on prior recursion experience.
The patterns covered, edit distance, subset sum and the knapsack family, 2D grid DP, and prefix sum, account for the majority of DP questions asked in real onsite loops. The four-pillar derivation framework also lets you handle unseen problems, which is what the harder interview rounds actually test.
LeetCode shows you problems one at a time with no shared framework. This course teaches the four pillars and the four patterns first, then drills problems through that lens, so you build a derivation skill instead of memorising 100 individual solutions.
A problem is a DP candidate when it asks for an optimal value (min, max, count, or yes/no reachability) and the solution to the full problem depends on solutions to smaller versions of the same problem (optimal substructure), with the same smaller subproblems being reused across the recursion (overlapping subproblems). If either condition is missing, DP will not help. Greedy works when you have optimal substructure without overlap. Divide and conquer works when you have neither. The course teaches three tests to apply on a new problem before you commit to a DP solution.
Memoisation is top-down: you write the recurrence as a recursive function and cache each subproblem the first time it is computed, so the dependency graph is explored lazily from the goal state inward. Tabulation is bottom-up: you allocate a table for every state in advance, seed the base cases, then fill the table in an order that respects the recurrence (typically a topological order of the state-space DAG). Memoisation is easier to write and only visits reachable states. Tabulation gives you tighter constant factors, no recursion stack, and an obvious place to apply space optimisations like keeping only the last row or column. The course covers both and shows when each is the right choice.
Yes. Once you finish all lessons and the practice problem set, codeintuition issues a shareable certificate you can post to LinkedIn or attach to a job application.