Module 11 of 12

Dynamic Programming

Lessons

About This Module

Dynamic programming answers one question extremely well: "am I solving the same smaller problem over and over?" Many recursive solutions repeat work, so a call like Fibonacci can take exponential time. Dynamic programming fixes this by solving each subproblem once, storing the answer, and reusing it, which often turns exponential time into polynomial time.

This module starts with how DP works: spotting overlapping subproblems and the two standard ways to remove the repeated work. Memoization is top-down, adding a cache to the recursion you already wrote. Tabulation is bottom-up, filling a table from the smallest subproblem to the answer.

The second half is about practice. Climbing Stairs is the simplest DP problem, House Robber adds a choice at every step (take this item or skip it), and the 0/1 Knapsack problem extends the idea to a two-dimensional table. The key skill is defining the subproblem and how it builds on smaller ones. Watch the lessons in order, then continue on to Greedy Algorithms & Problem Solving Patterns.

Lessons

4 videos
01

Dynamic Programming, Visualized (Memoization & Tabulation)

Dynamic programming explained visually: overlapping subproblems, memoization versus tabulation, and turning brute-force recursion into fast DP.

02

Climbing Stairs: Dynamic Programming (LeetCode 70)

The classic first DP problem, solved in Python: how each answer builds on the two before it, and how to reduce the space used.

03

House Robber, Visually Explained (LeetCode 198)

Solve House Robber with both top-down and bottom-up dynamic programming, walking through intuitive examples.

04

0/1 Knapsack Problem Explained Visually

The 0/1 Knapsack problem with dynamic programming, starting by building a table to track the maximum profit for each case.