Topic
Dynamic Programming interview questions
All 51 Dynamic Programming problems from the curated set, easiest first — a core topic for 9 of the 29 engineering roles.
- Easy
- 2
- Medium
- 34
- Hard
- 15
- Sheets
- 3
What Dynamic Programming is
Updated 2026-09-09Dynamic programming is a method for solving a complex problem by breaking it into overlapping subproblems, solving each subproblem only once, and remembering the answers in a lookup table. Instead of recalculating identical questions over and over, future steps look up previous answers directly. By assembling these saved pieces from the bottom up or storing them during recursion, a task that would take billions of steps finishes in a fraction of a second.
When to reach for it
Reach for dynamic programming when questions ask for the maximum profit, minimum cost, total number of distinct ways to achieve a goal, or whether a target can be formed. Signals include overlapping choices where making a choice now affects what choices remain later, but greedy picking fails to find the true global optimum. If drawing a recursive decision tree reveals the same subproblem states repeating across branches, dynamic programming is needed.
How to think about it
Identify the state variables that uniquely describe a subproblem, such as an array index and remaining capacity. Write the base cases first, representing states whose answers are known without calculation. Next, write the recurrence relation that expresses the current state using previously solved states, taking the minimum, maximum, or sum among your options. Build the solution either top-down by caching recursive returns in a memo table, or bottom-up by filling an array in topological dependency order. When each state depends only on the previous row, compress storage down to a single array.
What each operation costs
| Operation | Time |
|---|---|
| fill dynamic programming table of n states | O(n) |
| solve two-dimensional grid of m by n states | O(m * n) |
| space-optimized state transition keeping one row | O(n) |
What usually goes wrong
- Filling a bottom-up table in an order where the current cell needs values that have not been computed yet, reading uninitialized zeros.
- Failing to initialize base cases properly, such as filling a minimization table with zeros instead of infinity, which traps the answer at zero.
- Overwriting values in a 1D space-optimized knapsack array by scanning in the wrong direction, allowing the same item to be chosen multiple times.
Every Dynamic Programming problem, easiest first
- Climbing StairsEasy
- N-th Tribonacci NumberEasy
- Coin ChangeMedium
- Longest Increasing SubsequenceMedium
- Longest Common SubsequenceMedium
- Word BreakMedium
- Combination Sum IVMedium
- House RobberMedium
- House Robber IIMedium
- Decode WaysMedium
- Unique PathsMedium
- Jump GameMedium
- Jump Game IIMedium
- 0-1 Knapsack ProblemMedium
- Partition Equal Subset SumMedium
- Subset SumMedium
- Rod Cutting ProblemMedium
- Coin Change IIMedium
- Minimum Path SumMedium
- TriangleMedium
- Longest Bitonic SubsequenceMedium
- Count of Subset SumMedium
- Frog JumpMedium
- Max Sum of Non-Adjacent ElementsMedium
- Buy and Sell Stock with CooldownMedium
- Buy and Sell Stock with Transaction FeeMedium
- Longest String ChainMedium
- Number of Longest Increasing SubsequenceMedium
- Longest Palindromic SubsequenceMedium
- Minimum Insertions/Deletions to Convert StringMedium
- Unbounded KnapsackMedium
- Longest Arithmetic SubsequenceMedium
- Number of Ways to Reach Destination (DP on Grid)Medium
- Grid Unique Paths with ObstaclesMedium
- Minimum Falling Path SumMedium
- Count Square Submatrices with All OnesMedium
- Edit DistanceHard
- Burst BalloonsHard
- Regular Expression MatchingHard
- Matrix Chain MultiplicationHard
- Palindrome Partitioning IIHard
- Buy and Sell Stock IIIHard
- Buy and Sell Stock IVHard
- Wildcard MatchingHard
- Distinct SubsequencesHard
- Minimum Insertions to Make String PalindromeHard
- Shortest Common SupersequenceHard
- Maximum Rectangle in Binary MatrixHard
- Boolean ParenthesizationHard
- Chocolate Pickup (3D DP)Hard
- Maximum Sum Rectangle in 2D MatrixHard
Roles that need Dynamic Programming
If you are targeting one of these, Dynamic Programming sits early in your path rather than being optional.
Track Dynamic Programming in your role's order
Pick your target role and all 370 problems resequence to what that interview actually asks. Free.
Start freeDynamic Programming interview questions, answered
How many Dynamic Programming problems should I solve for interviews?
51 curated Dynamic Programming problems cover the patterns interviews repeat: 2 easy, 34 medium and 15 hard. They are drawn from 3 widely used sheets, deduplicated, and ordered easiest first.
Is Dynamic Programming actually asked in coding interviews?
Yes, though how much depends on the role. Dynamic Programming is a core topic for 9 of the 29 engineering roles tracked here, including SDE / Backend Engineer, ML Engineer, Information Retrieval Engineer. For other roles it is lower frequency and belongs later in a study plan.
Which Dynamic Programming problem should I start with?
Start with Climbing Stairs (Easy). The list on this page is ordered easiest first for that reason, so working top to bottom builds the pattern before the harder variations arrive.
Other topics
Problem set and role mapping as of .