Blind 75 Dynamic Programming Questions
12 problems · Free practice
Dynamic programming reuses answers to smaller subproblems. Start with a sentence defining one state, then write the choices that produce it. The recurrence should determine the evaluation order. Only reduce memory after the full state model is correct, because overwriting a value too early can change which subproblem it represents.
Practice dynamic programming
Climbing Stairs
EasyA staircase has n ≥ 1 steps. You can climb one or two steps at a time. Count the different ordered sequences of moves that reach the top exactly.
House Robber
MediumEach house along a street contains a nonnegative amount. Find the maximum total obtainable without choosing two neighboring houses. Choosing none is allowed.
House Robber II
MediumHouses form a circle and have nonnegative amounts. Maximize the sum of chosen houses without choosing any neighbors, including the first and last together.
Longest Palindromic Substring
MediumReturn a longest contiguous substring that reads the same forward and backward. If several have the same maximum length, any is acceptable.
Palindromic Substrings
MediumCount all nonempty contiguous palindromic substrings. Substrings at different positions count separately even when their text is identical.
Decode Ways
MediumA digit string encodes letters with 1 → A through 26 → Z. Count valid decodings. A zero cannot stand alone, and codes cannot begin with zero. The input is nonempty.
Coin Change
MediumGiven positive coin denominations and a nonnegative amount, find the fewest coins needed to make that amount with unlimited copies. Return −1 when it is impossible.
Maximum Product Subarray
MediumFind the largest product of any nonempty contiguous subarray of a nonempty integer array. Values may be positive, negative, or zero.
Word Break
MediumDecide whether a string can be split into one or more words from a dictionary of nonempty strings. Dictionary words can be reused. Treat an empty input as segmentable.
Longest Increasing Subsequence
MediumReturn the length of the longest strictly increasing subsequence of an integer array. Chosen elements keep their order but need not be adjacent.
Unique Paths
MediumCount paths from the top-left to the bottom-right of an m×n grid, with m,n ≥ 1. Each move goes one cell right or down. There are no obstacles.
Longest Common Subsequence
MediumFind the length of the longest sequence obtainable from each of two strings by deleting characters without reordering those kept.
What to focus on
- Describe the meaning of each state in words, including its indices.
- Identify base cases and impossible states separately.
- For counting problems, check whether changing loop order counts permutations instead of combinations.