DOKICODE
Study room

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.

465 problemsRating 1262–312520 Chapters
Open the study room

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

II. Grid & Matrix DP

III. Knapsack DP

§3.5 Tree Knapsack (Optional)Optional

ProblemRating
3562. Maximum Profit From Trading Stocks with Discounts2458

IV. Classic Linear DP (LCS/LIS)

V. Partition DP

§5.1 Partition Decision

ProblemRating
2369. Check If There Is a Valid Partition for the Array1780
139. Word BreakUnrated

VI. State Machine DP

VII. Linear DP Extensions

§7.6 Multidimensional DP

ProblemRating
2222. Number of Ways to Select Buildings1657
2826. Sorting Three Groups1721
2400. Number of Ways to Reach a Position After Exactly K Steps1751
1262. Greatest Sum Divisible by Three1762
3332. Maximum Points Tourist Can Earn1828
3176. Find the Maximum Length of a Good Subsequence I1849
1269. Number of Ways to Stay in the Same Place After Some Steps1854
3250. Find the Count of Monotonic Pairs I1898
3218. Minimum Cost for Cutting Cake IUnrated
3122. Minimum Number of Operations to Satisfy Conditions1905
576. Out of Boundary PathsUnrated
403. Frog JumpUnrated
3725. Count Ways to Choose Coprime Integers From Rows1982
1223. Dice Roll Simulation2008
1320. Minimum Distance to Type a Word Using Two Fingers2028
3366. Minimum Array Sum2040
1575. Count All Possible Routes2055
3154. Find Number of Ways to Reach the K Th Stair2071
2318. Number of Distinct Roll Sequences2090
3469. Find Minimum Cost to Remove Array Elements2112
2746. Decremental String Concatenation2126
1444. Number of Ways of Cutting a Pizza2127
3320. Count the Number of Winning Sequences2153
3429. Paint House IV2166
2896. Apply Operations to Make Two Strings Equal2172
1420. Build Array Where You Can Find the Maximum Exactly K Comparisons2176
3193. Count the Number of Inversions2266
1079. Letter Tile PossibilitiesUnrated
1866. Number of Ways to Rearrange Sticks with K Sticks Visible2333
2312. Selling Pieces of Wood2363
3177. Find the Maximum Length of a Good Subsequence II2365
1884. Egg Drop with 2 Eggs AND N FloorsUnrated
887. Super Egg Drop2377
920. Number of Music Playlists2400
3336. Find the Number of Subsequences with Equal Gcd2403
1388. Pizza with 3n Slices2410
903. Valid Permutations for Di Sequence2433
1900. The Earliest AND Latest Rounds Where Players Compete2455
1531. String Compression II2576
1883. Minimum Skips to Arrive at Meeting on Time2588
964. Least Operators to Express Number2594
3343. Count Number of Balanced Permutations2615
1787. Make the XOR of All Segments Equal to Zero2640
3509. Maximum Product of Subsequences with an Alternating Sum Equal to K2703
3441. Minimum Cost Good Caption2765
3539. Find Sum of Array Product of Magical Sequences2694
2060. Check If an Original String Exists Given Two Encoded Strings2804
2809. Minimum Time to Make Array Sum at Most X2979
3003. Maximize the Number of Partitions After Operations3039
3225. Maximum Score From Grid Operations3028

VIII. Interval DP

IX. Bitmask DP

§9.3 Traveling Salesperson Problem (TSP)

ProblemRating
943. Find the Shortest Superstring2186

X. Digit DP

§10.2 Sum of Valid Element Values

ProblemRating
233. Number of Digit OneUnrated
3753. Total Waviness of Numbers in Range II2297

XI. Optimized DP

§11.5 Trie-Optimized DP

ProblemRating
139. Word BreakUnrated
2707. Extra Characters in a StringUnrated
472. Concatenated Words2300

XII. Tree DP

§12.2 Tree Maximum Independent Set

ProblemRating
337. House Robber IIIUnrated
2646. Minimize the Total Price of the Trips2238
3544. Subtree Inversion Sum2545

§12.3 Minimum Dominating Set on Trees

ProblemRating
968. Binary Tree Cameras2124

XIII. Graph DP

XIV. Game Theory DP

XV. Probability & Expected Value DP

Special Topic: Printing Concrete Solutions

Special Topic: Prefix-Suffix Decomposition

Special Topic: Prefix-Suffix Decomposition

ProblemRating
724. Find Pivot IndexUnrated
1991. Find the Middle Index in ArrayUnrated
3707. Equal Score Substrings1262
2270. Number of Ways to Split Array1334
2256. Minimum Average Difference1395
1422. Maximum Score After Splitting a StringUnrated
238. Product of Array Except SelfUnrated
1493. Longest Subarray of 1s After Deleting One Element1423
845. Longest Mountain in Array1437
2012. Sum of Beauty in the Array1468
2909. Minimum Sum of Mountain Triplets II1479
2483. Minimum Penalty for a Shop1495
1525. Number of Good Ways to Split a String1500
3583. Count Special Triplets1510
3354. Make Array Elements Equal to ZeroUnrated
1930. Unique Length 3 Palindromic Subsequences1533
2874. Maximum Value of an Ordered Triplet II1583
1664. Ways to Make a Fair Array1590
123. Best Time to Buy AND Sell Stock IIIUnrated
3698. Split Array with Minimum Difference1649
3598. Longest Common Prefix Between Adjacent Strings After Removals1655
2222. Number of Ways to Select Buildings1657
1031. Maximum Sum of Two Non Overlapping Subarrays1680
689. Maximum Sum of 3 Non Overlapping SubarraysUnrated
2420. Find All Good Indices1695
2100. Find Good Days to Rob the Bank1702
926. Flip String to Monotone IncreasingUnrated
334. Increasing Triplet SubsequenceUnrated
1653. Minimum Deletions to Make String Balanced1794
1186. Maximum Subarray Sum with One Deletion1799
3738. Longest Non Decreasing Subarray After Replacing at Most One Element1811
42. Trapping Rain WaterUnrated
2711. Difference of Number of Distinct Values on DiagonalsUnrated
1477. Find Two Non Overlapping Sub Arrays Each with Target Sum1851
1671. Minimum Number of Removals to Make Mountain Array1913
2906. Construct Product Matrix2075
3334. Find the Maximum Factor Score of ArrayUnrated
2167. Minimum Time to Remove All Cars Containing Illegal Goods2219
2484. Count Palindromic Subsequences2223
2163. Minimum Difference in Sums After Removal of Elements2225
2565. Subsequence with the Minimum Score2432
1995. Count Special QuadrupletsUnrated
2552. Count Increasing Quadruplets2433
3302. Find the Lexicographically Smallest Valid Sequence2474
3404. Count Special Subsequences2445
3303. Find the Occurrence of First Almost Equal Substring2509
3410. Maximize Subarray Sum After Removing All Occurrences of One Element2844
3003. Maximize the Number of Partitions After Operations3039

Special Topic: Coordinate Transformation

Special Topic: Jump Game Variations

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