KatInterview

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.

Problems137

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-matchingrecursion
  • Grid 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-sum
  • Enumerate 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-gradedbacktrackingrecursionsortingcombinations
  • Count 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-numbers
  • Find 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-substring
  • Compute 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-programminggridmatrixoptimization
  • Pick 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-selection
  • Tests dynamic programming with unbounded resources to compute the minimal coin count for a target value, handling impossible cases.

    Auto-gradeddynamic-programmingcoin-changeoptimization
  • Tests understanding of optimal stopping via backward induction and dynamic threshold computation.

    Auto-gradedoptimal-stoppingbackward-inductionexpected-value
  • Given payer/payee/amount triples, compute net balances and return an optimal (minimum-count) set of settlement transfers that zeroes everyone out.

    Model answerbitmask-dpgreedysubset-sumaccounting
  • Tests bitmask dynamic programming (Held–Karp) to find the minimum-cost Hamiltonian cycle in a small directed weighted graph.

    Auto-gradedbitmask-dptraveling-salesmangraphs
  • Tests dynamic programming on graphs, topological ordering, and systematic state-space enumeration with path-length constraints.

    Auto-gradedgraphstopological-sortdag2d-dp
  • Computes the maximum path sum descending through a triangular grid, both unconstrained and when forced through a specific cell.

    Auto-gradeddynamic-programmingpathsoptimization
  • Tests 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-programmingknapsackarrays
  • Tests whether a candidate can apply 0/1 knapsack dynamic programming to maximize total reward without exceeding a fixed spending cap.

    Auto-gradeddynamic-programmingknapsackoptimization
  • Maximize stock trading profit given a cap on total transactions and a per-sale fee, using a unified DP state machine.

    Model answerdynamic-programmingstate-machinegreedy
  • Tests dynamic programming on a coin-change problem where decimal monetary values must be safely converted to integers before solving.

    Auto-gradeddynamic-programmingdecimal-precisioncoin-change
  • Tests understanding of dynamic programming through finding the maximum sum achievable by selecting adjacent elements from an array.

    Auto-gradedarrayskadanesubarrayoptimization
  • Tests 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-windowprobability
  • Count how many digit-sum values tie for the most occurrences among integers 1 through n.

    Model answerdigit-dpcombinatoricsmath
  • Tests string parsing for RLE decoding and interval DP to find the shortest valid re-encoding when patterns are capped at length K.

    Auto-gradedstringsdynamic-programmingcompression
  • Tests recursive game-tree traversal with memoization to count distinct play sequences by outcome.

    Auto-gradedrecursionmemoizationgame-theory
  • Tests understanding of dynamic programming optimization using binary search and greedy subsequence construction with the patience sorting technique.

    Auto-gradedbinary-searchsubsequencesgreedy
  • Return 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-pass
  • Tests backtracking with memoization to find the smallest number of payments needed to settle net balances across multiple participants.

    Auto-gradedbacktrackingmemoizationcombinatorial-search
  • Tests modeling a stochastic process as a Markov chain and solving it with dynamic programming using conditional expectation.

    Auto-gradedprobabilityexpectationmarkov-chainrecurrence
  • Compute 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-programming
  • Tests dynamic programming on 2D grids by computing the total count of square submatrices containing only ones.

    Auto-gradeddynamic-programmingmatrices2d-dp
  • Assign 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-hardness
  • Tests backtracking with incremental precedence-aware evaluation to enumerate all +/* expressions over a number sequence that sum to a given target.

    Auto-gradedbacktrackingrecursionoperator-precedence

More topics