Backend Developer
Dynamic programming questions
136 questions on Dynamic programming for backend developers, easiest first.
Easy 38
- Signs that a problem suits DPeasy
- What memoisation meanseasy
- What tabulation meanseasy
- Cost of plain recursive Fibonaccieasy
- Fibonacci after adding a cacheeasy
- Recursion with no base caseeasy
- Ways to climb five stairseasy
- Hidden memory cost of recursioneasy
- Why merge sort is not DPeasy
- When the greedy coin choice failseasy
- Built-in memoisation in Pythoneasy
- Robbing houses that are not neighbourseasy
- The first step in designing a DPeasy
- Fibonacci with two variableseasy
- Cheapest way up the stairseasy
- Paths across a 3 × 7 grideasy
- Grid paths with blocked cellseasy
- Cheapest path through a cost grideasy
- What 0/1 knapsack meanseasy
- Unbounded and 0/1 knapsackeasy
- Subsequence and substringeasy
- Longest common subsequence of two stringseasy
- Operations counted by edit distanceeasy
- Edit distance from kitten to sittingeasy
- Table size for a two-string DPeasy
- Common substring versus common subsequenceeasy
- Cost of the knapsack DPeasy
- Order to fill a right-or-down grid tableeasy
- Palindromic substrings in "aaa"easy
- Can some items add up to exactly Seasy
- The pattern behind backtrackingeasy
- Number of subsets of four itemseasy
- Orderings of four distinct itemseasy
- What makes a greedy algorithm correcteasy
- Booking the most meetings in one roomeasy
- What pruning does in a searcheasy
- Recursive maximum depth of a treeeasy
- Call stack depth of recursive traversaleasy
Medium 55
- Fewest intervals to removemedium
- Where to start a circular routemedium
- Fewest coins for an amountmedium
- Ways to make an amount from coinsmedium
- Loop order in coin countingmedium
- Longest increasing subsequence lengthmedium
- What the O(n log n) LIS array holdsmedium
- Largest sum of a contiguous blockmedium
- Kadane on all-negative numbersmedium
- Ways to decode a digit stringmedium
- Decoding a string that starts with zeromedium
- Splitting text into dictionary wordsmedium
- Coin change when the amount cannot be mademedium
- Cache key that forgets an argumentmedium
- Memoised recursion hits RecursionErrormedium
- Houses arranged in a circlemedium
- Largest product of a contiguous blockmedium
- Estimating a DP’s running timemedium
- Distinct BSTs from three keysmedium
- Stock trading with a cooldown daymedium
- Fewest perfect squares adding to 12medium
- Number of calls in plain recursive fib(5)medium
- Direction of the capacity loopmedium
- Best value in a small knapsackmedium
- Splitting into two equal halvesmedium
- Plus and minus signs that reach a targetmedium
- Longest palindromic subsequencemedium
- Longest palindromic substring in O(1) spacemedium
- Fill order for interval DPmedium
- Cheapest way to multiply three matricesmedium
- The trick in burst balloonsmedium
- Edit distance with less memorymedium
- Largest square of 1s in a matrixmedium
- Ways a word appears as a subsequencemedium
- Checking an interleaving of two stringsmedium
- Handling "*" in regex matching DPmedium
- Wildcard "*" versus regex "*"medium
- Knapsack with two limitsmedium
- House robber on a treemedium
- Two-row LCS cannot show the sequencemedium
- Printing an LCS from a full tablemedium
- Minimum starting health in a dungeonmedium
- Solutions to the eight queens puzzlemedium
- Subsets when the input has repeatsmedium
- Combination sum with reusable numbersmedium
- All results come out emptymedium
- Can you reach the last indexmedium
- Where value-per-kg greedy worksmedium
- Finding the start of a circular fuel routemedium
- How Huffman coding builds its treemedium
- Fewest bookings to cancelmedium
- Checking if a tree is a mirror of itselfmedium
- Checking balance in one passmedium
- Memoizing a recursive functionmedium
- Why fib(50) never finishesmedium
Hard 43
- Least ship capacity for a deadlinehard
- Most meetings in one roomhard
- Fewest arrows for overlapping balloonshard
- Remove k digits for the smallest numberhard
- Stock trading with a fee per tradehard
- Stock DP with at most k tradeshard
- Memo that never hits in JavaScripthard
- A memo cache in a long-running serverhard
- When top-down beats bottom-uphard
- Splitting 10 for the largest producthard
- Counting DP mod 1e9+7 in JavaScripthard
- Fibonacci for a huge nhard
- Tiling a 2 × 4 board with dominoeshard
- Taking a value removes its neighbourshard
- Nesting envelopes inside each otherhard
- When adding a cache does not helphard
- Is O(n × amount) polynomial?hard
- How many longest increasing subsequenceshard
- Painting houses with many colours fasthard
- Bitmask DP for a 20-stop delivery routehard
- The "tight" flag in digit DPhard
- Two eggs and a 100-floor buildinghard
- Knapsack with a capacity of a billionhard
- Shortest string containing two stringshard
- Fewest cuts into palindromeshard
- Two players taking from either endhard
- Why two greedy passes failhard
- Ways two dice add up to 7hard
- When a recurrence cannot be tabulatedhard
- Matching customer names with typoshard
- Breaking text into neat lineshard
- Which items did the knapsack takehard
- Longest increasing path in a matrixhard
- Edit distance on two large fileshard
- Speeding up a Sudoku solverhard
- Balanced strings of three bracket pairshard
- Bug in a grid word searchhard
- Proving a greedy rule is optimalhard
- CPU tasks with a cooldownhard
- Fewest rooms for overlapping meetingshard
- Recursive traversal crashes on big inputhard
- Maximum path sum with negative valueshard
- Topological sort on a 200,000-step chainhard