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 61–90 of 137 results
Decide whether a whole text matches a pattern with '.' and '*' wildcards, using prefix-based dynamic programming over text and pattern positions.
Auto-gradeddynamic-programmingstringspattern-matchingrecursionGrid dynamic programming: find the route with the largest sum from the bottom-left to the top-right cell when only moving up or right.
Auto-gradeddynamic-programminggridmatrixpath-sumEnumerate every distinct multiset of values from a list with repeats that adds up to a goal, using each position at most once, via sorted backtracking with duplicate skipping.
Auto-gradedbacktrackingrecursionsortingcombinationsCount the distinct binary search trees on keys 1..n by splitting on the root and combining independent subtree counts with dynamic programming.
Auto-gradeddynamic-programmingcombinatoricsbinary-search-treecatalan-numbersFind the longest block shared with a second string after optionally deleting one character from the first, using an O(n*m) DP with a deletion-used state.
Auto-gradeddynamic-programmingstringslongest-common-substringCompute the minimum total cost of a route from the top-left to the bottom-right of a grid when only right and down moves are allowed, using dynamic programming.
Auto-gradeddynamic-programminggridmatrixoptimizationPick values from a row so that no two chosen positions are neighbors, maximizing the total, which tests recognizing and implementing a simple one-dimensional dynamic programming recurrence.
Auto-gradeddynamic-programmingarraysnon-adjacent-selectionTests dynamic programming with unbounded resources to compute the minimal coin count for a target value, handling impossible cases.
Auto-gradeddynamic-programmingcoin-changeoptimizationTests understanding of optimal stopping via backward induction and dynamic threshold computation.
Auto-gradedoptimal-stoppingbackward-inductionexpected-valueGiven payer/payee/amount triples, compute net balances and return an optimal (minimum-count) set of settlement transfers that zeroes everyone out.
Model answerbitmask-dpgreedysubset-sumaccountingTests bitmask dynamic programming (Held–Karp) to find the minimum-cost Hamiltonian cycle in a small directed weighted graph.
Auto-gradedbitmask-dptraveling-salesmangraphsTests dynamic programming on graphs, topological ordering, and systematic state-space enumeration with path-length constraints.
Auto-gradedgraphstopological-sortdag2d-dpComputes the maximum path sum descending through a triangular grid, both unconstrained and when forced through a specific cell.
Auto-gradeddynamic-programmingpathsoptimizationTests whether a candidate can apply 0/1 knapsack DP to find the minimum number of items from a list whose weights sum to exactly a given target.
Auto-gradeddynamic-programmingknapsackarraysTests whether a candidate can apply 0/1 knapsack dynamic programming to maximize total reward without exceeding a fixed spending cap.
Auto-gradeddynamic-programmingknapsackoptimizationMaximize stock trading profit given a cap on total transactions and a per-sale fee, using a unified DP state machine.
Model answerdynamic-programmingstate-machinegreedyTests dynamic programming on a coin-change problem where decimal monetary values must be safely converted to integers before solving.
Auto-gradeddynamic-programmingdecimal-precisioncoin-changeTests understanding of dynamic programming through finding the maximum sum achievable by selecting adjacent elements from an array.
Auto-gradedarrayskadanesubarrayoptimizationTests whether a candidate can build an O(n) sliding-window DP to compute the probability that a random accumulation process stops within a given score ceiling.
Auto-gradeddynamic-programmingsliding-windowprobabilityCount how many digit-sum values tie for the most occurrences among integers 1 through n.
Model answerdigit-dpcombinatoricsmathTests string parsing for RLE decoding and interval DP to find the shortest valid re-encoding when patterns are capped at length K.
Auto-gradedstringsdynamic-programmingcompressionTests recursive game-tree traversal with memoization to count distinct play sequences by outcome.
Auto-gradedrecursionmemoizationgame-theoryTests understanding of dynamic programming optimization using binary search and greedy subsequence construction with the patience sorting technique.
Auto-gradedbinary-searchsubsequencesgreedyReturn a series' steepest peak-to-trough drop with its indices, the best one-buy-one-sell gain, and the minimum coin count for a target.
Auto-gradedarraysdynamic-programminggreedysingle-passTests backtracking with memoization to find the smallest number of payments needed to settle net balances across multiple participants.
Auto-gradedbacktrackingmemoizationcombinatorial-searchTests modeling a stochastic process as a Markov chain and solving it with dynamic programming using conditional expectation.
Auto-gradedprobabilityexpectationmarkov-chainrecurrenceCompute critical-path latency and peak concurrency for a task DAG, then find minimum-cost checkpoint placement under a sliding-window coverage constraint.
Model answerdagtopological-sortsliding-windowdynamic-programmingTests dynamic programming on 2D grids by computing the total count of square submatrices containing only ones.
Auto-gradeddynamic-programmingmatrices2d-dpAssign and sequence three jobs across two parallel stations to minimize makespan, handling sequence-dependent changeovers, a precedence constraint, and a station blackout period.
Model answerschedulingcombinatorial-optimizationbranch-and-boundNP-hardnessTests backtracking with incremental precedence-aware evaluation to enumerate all +/* expressions over a number sequence that sum to a given target.
Auto-gradedbacktrackingrecursionoperator-precedence