Topic
Dynamic Programming interview problems
States, transitions and memoization on sequences and grids. 137 original problems, each with hidden test cases you can run in the browser.
5 easy96 medium36 hard
Showing 1–30 of 137 results
Evaluate string encoding, ambiguous Morse code decoding via dynamic programming, and spatial coverage checking for network members.
Auto-gradeddynamic-programmingstringsarraysgeometryFind the longest chain of strictly rising values in a grid using only up, down, left, right steps, which tests DP over an implicit DAG with a valid processing order.
Auto-gradeddynamic-programminggridtopological-ordermemoizationFind the maximum priority total achievable among non-overlapping interval tasks, prioritizing task count first then total priority.
Auto-gradeddynamic-programminggreedy-intervalsbinary-searchDetermine the minimal set of non-root node deletions required to trim a multi-child tree's height down to a target limit under node-promotion rules.
Model answertrees-graphsdynamic-programmingtree-dpAggregate daily resource usages and calculate optimal allocations under unrestricted and migration-bounded pool selection constraints using dynamic programming.
Model answerarraysdynamic-programminggreedy-intervalsFind the area of the largest square made only of '1' cells in a grid of character digits, using a dynamic programming recurrence that can be compressed to a single row of state.
Auto-gradeddynamic-programmingmatrixspace-optimization2d-gridFind the minimum number of worst-case letter guesses required to isolate a hidden word against an adversarial host.
Auto-gradeddynamic-programmingbit-manipulationminimaxmemoizationChoose a budget-limited subset of cards and an order to maximize a score updated by an affine rule, testing subset and ordering search and exchange-argument reasoning.
Auto-gradedsubset-searchpermutationsexchange-argumentknapsackCount non-decreasing sequences of integers in [0, 5000] whose i-th element has a given digit sum, using DP over candidate values with prefix sums, modulo 1,000,000,007.
Auto-gradeddynamic-programmingprefix-sumstwo-pointerscountingGroup jobs with two resource demands into the fewest identical cabinets, using exact search with symmetry breaking and pruning (2D vector bin packing).
Auto-gradedbin-packingbacktrackingbitmaskcombinatorial-optimizationCount placements of k items in n slots with at least m maximal runs of length 2 or more, using a counting DP or combinatorics, and return the exact probability.
Auto-gradedcombinatoricsprobabilitydynamic-programmingcountingFind the shortest nested repeat encoding of a string with interval DP over splits and repeats, using a fixed tie-break order so the output is unique.
Auto-gradeddynamic-programmingstringsrecursionmemoizationTests one-dimensional dynamic programming: pick values from a sequence so no two neighbors are both chosen, maximizing the total.
Auto-gradeddynamic-programmingarraysoptimizationDecide the winner of a two-player impartial game where piles are fused under a size cap, using memoized game-tree search over canonical multiset states.
Auto-gradedgame-theorymemoizationbacktrackingbitmask-statesChoose one of three colors per day to minimize total cost with no color on two adjacent days, then return the actual sequence using DP with backtracking.
Auto-gradeddynamic-programmingpath-reconstructionarraysPick non-overlapping time slots, where one may begin exactly as another finishes, to maximize total payout; tests weighted interval scheduling with sorting, DP and binary search.
Auto-gradeddynamic-programmingbinary-searchintervalssortingCompute Levenshtein distance with dynamic programming and pick, for each query, the closest dictionary word with a stable first-index tie-break.
Auto-gradededit-distancedynamic-programmingstringstie-breakingCount length-n digit strings formed by knight jumps on a phone keypad, modulo 1e9+7, using DP over a small fixed graph.
Auto-gradeddynamic-programminggraphmodular-arithmeticcountingCount the distinct positive totals obtainable from a limited supply of coins per denomination, testing bounded subset-sum reachability with DP or bitset techniques.
Auto-gradeddynamic-programmingsubset-sumbounded-knapsackbitsetCount the ways to cut a digit string into prime-valued pieces without leading zeros, using prefix dynamic programming plus a fast primality check, modulo 1,000,000,007.
Auto-gradeddynamic-programmingprimality-teststringscountingDecide whether to stop or roll in a dice accumulation game where the first zero resets your total and the second zero wipes you out, using DP over (total, reset-used) states.
Auto-gradeddynamic-programmingexpected-valueoptimal-stoppingprobabilitySimulate task batch execution across a sequential multi-stage pipeline and count total units completed within a time limit.
Auto-gradedarrayssimulationdynamic-programminggreedy-intervalsCompute the maximum total from a line of non-negative numbers when no two neighboring entries may both be picked, using linear-time dynamic programming.
Auto-gradeddynamic-programmingarraytake-or-skiphouse-robberChoose one vendor per day to minimize total price with no vendor on consecutive days, returning the plan with a fixed tie-break; tests DP, backtracking, and best/second-best.
Auto-gradeddynamic-programmingpath-reconstructionoptimizationarraysSegment a spaceless string into dictionary words and return the lexicographically smallest valid sentence, or None if impossible; tests suffix DP plus greedy reconstruction.
Auto-gradeddynamic-programmingstringsgreedyword-breakParse CSV text with quoted fields, then find the longest chain of cities with increasing longitude and non-decreasing latitude, breaking ties by the smallest list of names.
Auto-gradedcsv-parsinglongest-increasing-subsequencedag-dplexicographic-tiebreakFind the minimum cost to complete a full circuit starting and ending at node 0, visiting all other nodes exactly once with asymmetric leg costs.
Auto-gradeddynamic-programmingbit manipulationgraphCompute the best total gain from repeatedly buying and selling a single share of a stock when each sale costs a flat commission, using a two-state dynamic program.
Auto-gradeddynamic-programmingstate-machinestocksgreedyCount arrangements of 1..m with exactly n out-of-order pairs, modulo 10^9+7, using a DP over insertion positions optimized with a sliding-window sum.
Auto-gradeddynamic-programmingcombinatoricspermutationssliding-windowDecide whether removing parentheses to satisfy per-digit quotas can leave a balanced bracket string, using a DP over balance and removal count.
Auto-gradeddynamic-programmingstringsparenthesesstate-compression