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 1–30 of 137 results

  • Evaluate string encoding, ambiguous Morse code decoding via dynamic programming, and spatial coverage checking for network members.

    Auto-gradeddynamic-programmingstringsarraysgeometry
  • Find 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-ordermemoization
  • Find the maximum priority total achievable among non-overlapping interval tasks, prioritizing task count first then total priority.

    Auto-gradeddynamic-programminggreedy-intervalsbinary-search
  • Determine 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-dp
  • Aggregate daily resource usages and calculate optimal allocations under unrestricted and migration-bounded pool selection constraints using dynamic programming.

    Model answerarraysdynamic-programminggreedy-intervals
  • Find 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-grid
  • Find the minimum number of worst-case letter guesses required to isolate a hidden word against an adversarial host.

    Auto-gradeddynamic-programmingbit-manipulationminimaxmemoization
  • Choose 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-argumentknapsack
  • Count 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-pointerscounting
  • Group 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-optimization
  • Count 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-programmingcounting
  • Find 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-programmingstringsrecursionmemoization
  • Tests one-dimensional dynamic programming: pick values from a sequence so no two neighbors are both chosen, maximizing the total.

    Auto-gradeddynamic-programmingarraysoptimization
  • Decide 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-states
  • Choose 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-reconstructionarrays
  • Pick 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-searchintervalssorting
  • Compute 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-breaking
  • Count 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-arithmeticcounting
  • Count 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-knapsackbitset
  • Count 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-teststringscounting
  • Decide 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-stoppingprobability
  • Simulate task batch execution across a sequential multi-stage pipeline and count total units completed within a time limit.

    Auto-gradedarrayssimulationdynamic-programminggreedy-intervals
  • Compute 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-robber
  • Choose 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-reconstructionoptimizationarrays
  • Segment 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-break
  • Parse 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-tiebreak
  • Find 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 manipulationgraph
  • Compute 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-machinestocksgreedy
  • Count 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-window
  • Decide 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

More topics