Dynamic Programming
Dynamic programming builds the answer from answers to smaller versions of the same problem and stores them so nothing is computed twice. The hard part is deciding what a state means; the code itself is often short.
It is the largest plan, 465 problems in 20 chapters. It begins with introductory and grid DP, then knapsack, LCS and LIS, partition and state machine DP, and moves on to interval, bitmask, digit, tree, graph, game theory and probability DP, plus special topics such as printing an actual solution and jump game variations. It suits anyone who is comfortable with recursion and wants a long, ordered path through DP.
Want company while you work through this list? Sign in, open the study room, and your heroine will bring you the problems one at a time.
I. Introductory DP
§1.1 Climbing Stairs
| Problem | Rating |
|---|---|
| 70. Climbing Stairs | Unrated |
| 746. Min Cost Climbing Stairs | 1500 |
| 3693. Climbing Stairs II | 1560 |
| 377. Combination Sum IV | 1600 |
| 2466. Count Ways to Build Good Strings | 1694 |
| 2266. Count Number of Texts | 1857 |
§1.2 House Robber
| Problem | Rating |
|---|---|
| 198. House Robber | Unrated |
| 213. House Robber II | Unrated |
| 2320. Count Number of Ways to Place Houses | 1608 |
| 740. Delete AND Earn | Unrated |
| 3186. Maximum Total Damage with Spell Casting | 1841 |
| 2140. Solving Questions with Brainpower | 1709 |
§1.3 Maximum Subarray Sum
II. Grid & Matrix DP
§2.1 Fundamentals
§2.2 Advanced
III. Knapsack DP
§3.1 0-1 Knapsack
§3.2 Unbounded Knapsack
| Problem | Rating |
|---|---|
| 322. Coin Change | Unrated |
| 518. Coin Change II | Unrated |
| 279. Perfect Squares | Unrated |
| 3592. Inverse Coin Change | 1701 |
| 1449. Form Largest Integer with Digits That Add Up to Target | 1927 |
§3.3 Bounded Knapsack (Optional)Optional
| Problem | Rating |
|---|---|
| 2585. Number of Ways to Earn Points | 1910 |
| 3333. Find the Original Typed String II | 2629 |
| 2902. Count of Sub Multisets with Bounded Sum | 2759 |
| 3489. Zero Array Transformation IV | Unrated |
§3.4 Grouped Knapsack
| Problem | Rating |
|---|---|
| 1155. Number of Dice Rolls with Target Sum | 1654 |
| 1981. Minimize the Difference Between Target AND Chosen Elements | 2010 |
| 2218. Maximum Value of K Coins From Piles | 2158 |
§3.5 Tree Knapsack (Optional)Optional
| Problem | Rating |
|---|---|
| 3562. Maximum Profit From Trading Stocks with Discounts | 2458 |
IV. Classic Linear DP (LCS/LIS)
§4.1 Longest Common Subsequence (LCS)
§4.2 Longest Increasing Subsequence (LIS)
V. Partition DP
§5.1 Partition Decision
| Problem | Rating |
|---|---|
| 2369. Check If There Is a Valid Partition for the Array | 1780 |
| 139. Word Break | Unrated |
§5.2 Optimal Partitioning
§5.3 Partitioning into a Fixed Number of Parts
VI. State Machine DP
§6.1 Best Time to Buy and Sell Stock
§6.2 State Machine Fundamentals
§6.3 Advanced State Machine DP
VII. Linear DP Extensions
§7.1 1D Linear DP
§7.2 Disjoint Intervals
§7.3 Subarray DP
§7.4 Valid Subsequence DP
§7.5 Subrectangle DP
§7.6 Multidimensional DP
VIII. Interval DP
§8.1 Longest Palindromic Subsequence
§8.2 Interval DP
IX. Bitmask DP
§9.1 Permutation Bitmask DP I (Independent)
| Problem | Rating |
|---|---|
| 526. Beautiful Arrangement | Unrated |
| 1799. Maximize Score After N Operations | Unrated |
| 3533. Concatenated Divisibility | 2257 |
| 3530. Maximum Profit From Valid Topological Order in Dag | 2353 |
§9.2 Permutation Bitmask DP II (Neighbor-dependent)
§9.3 Traveling Salesperson Problem (TSP)
| Problem | Rating |
|---|---|
| 943. Find the Shortest Superstring | 2186 |
§9.4 Subset Bitmask DP
§9.5 Broken Profile DP
| Problem | Rating |
|---|---|
| 1411. Number of Ways to Paint N 3 Grid | 1845 |
| 1931. Painting a Grid with Three Different Colors | 2170 |
| 1659. Maximize Grid Happiness | 2655 |
| 980. Unique Paths III | Unrated |
§9.6 SOS DP (Sum over Subsets)
§9.7 Other Bitmask DP
X. Digit DP
§10.1 Count Valid Elements
§10.2 Sum of Valid Element Values
| Problem | Rating |
|---|---|
| 233. Number of Digit One | Unrated |
| 3753. Total Waviness of Numbers in Range II | 2297 |
§10.3 Other Digit DP
| Problem | Rating |
|---|---|
| 3677. Count Binary Palindromic Numbers | 2223 |
| 3348. Smallest Divisible Digit Product II | 3101 |
XI. Optimized DP
§11.1 Prefix Sum Optimized DP
§11.2 Monotonic Stack Optimized DP
| Problem | Rating |
|---|---|
| 1335. Minimum Difficulty of a Job Schedule | 2035 |
| 2866. Beautiful Towers II | 2072 |
| 2617. Minimum Number of Visited Cells in a Grid | 2582 |
§11.3 Monotonic Queue Optimized DP
§11.4 Fenwick Tree and Segment Tree Optimized DP
§11.5 Trie-Optimized DP
| Problem | Rating |
|---|---|
| 139. Word Break | Unrated |
| 2707. Extra Characters in a String | Unrated |
| 472. Concatenated Words | 2300 |
§11.6 Matrix Exponentiation Optimized DP
§11.7 Convex Hull Trick DP
| Problem | Rating |
|---|---|
| 3494. Find the Minimum Amount of Time to Brew Potions | Unrated |
| 3500. Minimum Cost to Divide Array Into Subarrays | Unrated |
| 3693. Climbing Stairs II | Unrated |
§11.8 WQS Binary Search (Aliens Trick)
§11.9 Other DP Optimizations
XII. Tree DP
§12.1 Tree Diameter
§12.2 Tree Maximum Independent Set
| Problem | Rating |
|---|---|
| 337. House Robber III | Unrated |
| 2646. Minimize the Total Price of the Trips | 2238 |
| 3544. Subtree Inversion Sum | 2545 |
§12.3 Minimum Dominating Set on Trees
| Problem | Rating |
|---|---|
| 968. Binary Tree Cameras | 2124 |
§12.4 Rerooting Tree DP
§12.5 Other Tree DP
XIII. Graph DP
XIII. Graph DP
| Problem | Rating |
|---|---|
| 3543. Maximum Weighted K Edge Path | 2110 |
| 913. Cat AND Mouse | 2800 |
| 1728. Cat AND Mouse II | 2849 |
XIV. Game Theory DP
XIV. Game Theory DP
| Problem | Rating |
|---|---|
| 1025. Divisor Game | 1435 |
| 877. Stone Game | 1590 |
| 486. Predict the Winner | Unrated |
| 1510. Stone Game IV | 1787 |
| 1690. Stone Game VII | 1951 |
| 1406. Stone Game III | 2027 |
| 1140. Stone Game II | 2035 |
| 1563. Stone Game V | 2087 |
| 464. Can I Win | Unrated |
| 1872. Stone Game VIII | 2440 |
| 913. Cat AND Mouse | 2800 |
| 1728. Cat AND Mouse II | 2849 |
XV. Probability & Expected Value DP
XV. Probability & Expected Value DP
| Problem | Rating |
|---|---|
| 688. Knight Probability in Chessboard | Unrated |
| 837. New 21 Game | 2350 |
| 1467. Probability of a Two Boxes Having the Same Number of Distinct Balls | 2357 |
| 808. Soup Servings | 2397 |
Special Topic: Printing Concrete Solutions
Special Topic: Printing Concrete Solutions
Special Topic: Prefix-Suffix Decomposition
Special Topic: Prefix-Suffix Decomposition
Special Topic: Coordinate Transformation
XVI. Coordinate / State Transformation
Special Topic: Jump Game Variations
Special Topic: Jump Game Variations
| Problem | Rating |
|---|---|
| 2770. Maximum Number of Jumps to Reach the Last Index | 1533 |
| 403. Frog Jump | Unrated |
| 1340. Jump Game V | 1866 |
| 1871. Jump Game VII | 1896 |
| 1696. Jump Game VI | 1954 |
| 975. Odd Even Jump | 2079 |
| 1654. Minimum Jumps to Reach Home | 2124 |
XVIII. Miscellaneous DP
It is the third plan on Track 2; the bounded knapsack and tree knapsack sections are marked optional and wait in the advanced lists, so the route keeps moving through the core chapters.
Ratings come from zerotrac's LeetCode contest ratings. Some problems have no zerotrac rating and are marked Unrated.
Open the study room