KatInterview

practice a little every day — you've got this ♡

Dynamic Programming Interview Problems

Practice 5965 original coding, SQL, system design, machine learning and behavioral problems across 15 topics. Coding and SQL problems run against hidden test cases right in your browser; every problem has hints and a worked solution, free.

5965
Problems
2208
Auto-graded
15
Topics
271
Added today

Showing 1–30 of 137 results

  • Dynamic ProgrammingMediumAuto-graded
    Process Morse Signals and Provider Coverage

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

    Dynamic Programmingdynamic-programmingstringsarraysgeometry
  • Dynamic ProgrammingMediumAuto-graded
    Climbing the Tallest Staircase Through a Height Map

    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.

    Dynamic Programmingdynamic-programminggridtopological-ordermemoization
  • Dynamic ProgrammingHardAuto-graded
    Maximize Priority Sum of Non-Overlapping Tasks

    Find the maximum priority total achievable among non-overlapping interval tasks, prioritizing task count first then total priority.

    Dynamic Programmingdynamic-programminggreedy-intervalsbinary-search
  • Dynamic ProgrammingMediumModel answer
    Prune Minimum Nodes from Tree to Satisfy Height Budget

    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.

    Dynamic Programmingtrees-graphsdynamic-programmingtree-dp
  • Dynamic ProgrammingHardModel answer
    Maximize Allocation Across Server Pools with Migration Limits

    Aggregate daily resource usages and calculate optimal allocations under unrestricted and migration-bounded pool selection constraints using dynamic programming.

    Dynamic Programmingarraysdynamic-programminggreedy-intervals
  • Dynamic ProgrammingMediumAuto-graded
    Biggest Solid Block in a Binary Grid

    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.

    Dynamic Programmingdynamic-programmingmatrixspace-optimization2d-grid
  • Dynamic ProgrammingHardAuto-graded
    Adaptive Word Guessing Minimax Strategy

    Find the minimum number of worst-case letter guesses required to isolate a hidden word against an adversarial host.

    Dynamic Programmingdynamic-programmingbit-manipulationminimaxmemoization
  • Dynamic ProgrammingMediumAuto-graded
    Best Final Score from Affine Card Purchases Under a Budget

    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.

    Dynamic Programmingsubset-searchpermutationsexchange-argumentknapsack
  • Dynamic ProgrammingMediumAuto-graded
    Counting Sorted Sequences With Prescribed Digit Sums

    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.

    Dynamic Programmingdynamic-programmingprefix-sumstwo-pointerscounting
  • Dynamic ProgrammingHardAuto-graded
    Fewest Cabinets for Two-Resource Jobs

    Group jobs with two resource demands into the fewest identical cabinets, using exact search with symmetry breaking and pruning (2D vector bin packing).

    Dynamic Programmingbin-packingbacktrackingbitmaskcombinatorial-optimization
  • Dynamic ProgrammingMediumAuto-graded
    Probability of Adjacent Car Groups in a Random Parking Row

    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.

    Dynamic Programmingcombinatoricsprobabilitydynamic-programmingcounting
  • Dynamic ProgrammingMediumAuto-graded
    Shortest Nested Run-Length Encoding of a String

    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.

    Dynamic Programmingdynamic-programmingstringsrecursionmemoization
  • Dynamic ProgrammingMediumAuto-graded
    Best Haul from a Row of Cash Stations

    Tests one-dimensional dynamic programming: pick values from a sequence so no two neighbors are both chosen, maximizing the total.

    Dynamic Programmingdynamic-programmingarraysoptimization
  • Dynamic ProgrammingHardAuto-graded
    Coin Pile Fusion: Who Makes the Last Merge?

    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.

    Dynamic Programminggame-theorymemoizationbacktrackingbitmask-states
  • Dynamic ProgrammingMediumAuto-graded
    Booth Assignment Plan: Cheapest Non-Repeating Color Sequence

    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.

    Dynamic Programmingdynamic-programmingpath-reconstructionarrays
  • Dynamic ProgrammingMediumAuto-graded
    Maximum Earnings from Back-to-Back Booking Slots

    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.

    Dynamic Programmingdynamic-programmingbinary-searchintervalssorting
  • Dynamic ProgrammingMediumAuto-graded
    Nearest Word Lookup Using Minimum Edit Operations

    Compute Levenshtein distance with dynamic programming and pick, for each query, the closest dictionary word with a stable first-index tie-break.

    Dynamic Programmingedit-distancedynamic-programmingstringstie-breaking
  • Dynamic ProgrammingMediumAuto-graded
    Counting Knight-Walk Phone Numbers on a Keypad

    Count length-n digit strings formed by knight jumps on a phone keypad, modulo 1e9+7, using DP over a small fixed graph.

    Dynamic Programmingdynamic-programminggraphmodular-arithmeticcounting
  • Dynamic ProgrammingMediumAuto-graded
    Count Reachable Totals from a Bounded Coin Collection

    Count the distinct positive totals obtainable from a limited supply of coins per denomination, testing bounded subset-sum reachability with DP or bitset techniques.

    Dynamic Programmingdynamic-programmingsubset-sumbounded-knapsackbitset
  • Dynamic ProgrammingMediumAuto-graded
    Prime Segment Partitions of a Digit Sequence

    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.

    Dynamic Programmingdynamic-programmingprimality-teststringscounting
  • Dynamic ProgrammingMediumAuto-graded
    Stop or Roll: Ten-Sided Die With a One-Time Reset

    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.

    Dynamic Programmingdynamic-programmingexpected-valueoptimal-stoppingprobability
  • Dynamic ProgrammingMediumAuto-graded
    Calculate Processed Work Units in Pipelined Task Queues

    Simulate task batch execution across a sequential multi-stage pipeline and count total units completed within a time limit.

    Dynamic Programmingarrayssimulationdynamic-programminggreedy-intervals
  • Dynamic ProgrammingMediumAuto-graded
    Best Haul from a Line of Stalls Without Neighbors

    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.

    Dynamic Programmingdynamic-programmingarraytake-or-skiphouse-robber
  • Dynamic ProgrammingHardAuto-graded
    Daily Vendor Booking with No Immediate Repeats

    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.

    Dynamic Programmingdynamic-programmingpath-reconstructionoptimizationarrays
  • Dynamic ProgrammingMediumAuto-graded
    Smallest Sentence from a Spaceless String and Word List

    Segment a spaceless string into dictionary words and return the lexicographically smallest valid sentence, or None if impossible; tests suffix DP plus greedy reconstruction.

    Dynamic Programmingdynamic-programmingstringsgreedyword-break
  • Dynamic ProgrammingMediumAuto-graded
    Longest Eastward Chain of Cities from Raw CSV Text

    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.

    Dynamic Programmingcsv-parsinglongest-increasing-subsequencedag-dplexicographic-tiebreak
  • Dynamic ProgrammingMediumAuto-graded
    Optimal Closed Tour Cost Across Directed Locations

    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.

    Dynamic Programmingdynamic-programmingbit manipulationgraph
  • Dynamic ProgrammingMediumAuto-graded
    Stock Trading With a Per-Sale Commission

    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.

    Dynamic Programmingdynamic-programmingstate-machinestocksgreedy
  • Dynamic ProgrammingMediumAuto-graded
    Rearrangements of 1..m With a Fixed Number of Out-of-Order Pairs

    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.

    Dynamic Programmingdynamic-programmingcombinatoricspermutationssliding-window
  • Dynamic ProgrammingHardAuto-graded
    Balanced Parentheses After Digit-Driven Removals

    Decide whether removing parentheses to satisfy per-digit quotas can leave a balanced bracket string, using a DP over balance and removal count.

    Dynamic Programmingdynamic-programmingstringsparenthesesstate-compression