KatInterview

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

Dynamic Programming Interview Problems

Practice 5969 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.

5969
Problems
2211
Auto-graded
15
Topics
273
Added today

Showing 61–90 of 137 results

  • Dynamic ProgrammingHardAuto-graded
    Full-String Matching with Dot and Star Wildcards

    Decide whether a whole text matches a pattern with '.' and '*' wildcards, using prefix-based dynamic programming over text and pattern positions.

    Dynamic Programmingdynamic-programmingstringspattern-matchingrecursion
  • Dynamic ProgrammingMediumAuto-graded
    Maximum Ore Haul on a Climb-and-Step Grid Route

    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.

    Dynamic Programmingdynamic-programminggridmatrixpath-sum
  • Dynamic ProgrammingMediumAuto-graded
    Distinct Value Groups Summing to a Goal, Each Item Used Once

    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.

    Dynamic Programmingbacktrackingrecursionsortingcombinations
  • Dynamic ProgrammingMediumAuto-graded
    Counting Valid Ordered Binary Trees on n Labeled Nodes

    Count the distinct binary search trees on keys 1..n by splitting on the root and combining independent subtree counts with dynamic programming.

    Dynamic Programmingdynamic-programmingcombinatoricsbinary-search-treecatalan-numbers
  • Dynamic ProgrammingMediumAuto-graded
    Longest Shared Block After Removing One Character

    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.

    Dynamic Programmingdynamic-programmingstringslongest-common-substring
  • Dynamic ProgrammingMediumAuto-graded
    Cheapest Right-Down Route Through a Cost Grid

    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.

    Dynamic Programmingdynamic-programminggridmatrixoptimization
  • Dynamic ProgrammingMediumAuto-graded
    Best Haul from a Row of Stalls Without Adjacent Picks

    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.

    Dynamic Programmingdynamic-programmingarraysnon-adjacent-selection
  • Dynamic ProgrammingMediumAuto-graded
    Fewest Coins to Form Target Sum

    Tests dynamic programming with unbounded resources to compute the minimal coin count for a target value, handling impossible cases.

    Dynamic Programmingdynamic-programmingcoin-changeoptimization
  • Dynamic ProgrammingMediumAuto-graded
    Maximum Expected Value from Sequential Uniform Draws

    Tests understanding of optimal stopping via backward induction and dynamic threshold computation.

    Dynamic Programmingoptimal-stoppingbackward-inductionexpected-value
  • Dynamic ProgrammingMediumModel answer
    Fewest Transfers to Clear Everyone's Net Balance

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

    Dynamic Programmingbitmask-dpgreedysubset-sumaccounting
  • Dynamic ProgrammingHardAuto-graded
    Cheapest Round-Trip Inspection Tour

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

    Dynamic Programmingbitmask-dptraveling-salesmangraphs
  • Dynamic ProgrammingMediumAuto-graded
    Count Paths of Fixed Length in a DAG

    Tests dynamic programming on graphs, topological ordering, and systematic state-space enumeration with path-length constraints.

    Dynamic Programminggraphstopological-sortdag2d-dp
  • Dynamic ProgrammingMediumAuto-graded
    Best Path Sum in Triangle with Required Cell Constraint

    Computes the maximum path sum descending through a triangular grid, both unconstrained and when forced through a specific cell.

    Dynamic Programmingdynamic-programmingpathsoptimization
  • Dynamic ProgrammingMediumAuto-graded
    Fewest Items to Hit an Exact Weight Target

    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.

    Dynamic Programmingdynamic-programmingknapsackarrays
  • Dynamic ProgrammingMediumAuto-graded
    Maximum Reward Within a Spending Limit

    Tests whether a candidate can apply 0/1 knapsack dynamic programming to maximize total reward without exceeding a fixed spending cap.

    Dynamic Programmingdynamic-programmingknapsackoptimization
  • Dynamic ProgrammingMediumModel answer
    Stock Trading Profit with Transaction Limits and Fees

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

    Dynamic Programmingdynamic-programmingstate-machinegreedy
  • Dynamic ProgrammingMediumAuto-graded
    Minimum Coins to Reach a Money Amount

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

    Dynamic Programmingdynamic-programmingdecimal-precisioncoin-change
  • Dynamic ProgrammingMediumAuto-graded
    Largest Sum in Any Consecutive Sequence

    Tests understanding of dynamic programming through finding the maximum sum achievable by selecting adjacent elements from an array.

    Dynamic Programmingarrayskadanesubarrayoptimization
  • Dynamic ProgrammingMediumAuto-graded
    Score Bust Probability: Stop When You Hit the Target

    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.

    Dynamic Programmingdynamic-programmingsliding-windowprobability
  • Dynamic ProgrammingMediumModel answer
    Digit-Sum Frequency Peaks

    Count how many digit-sum values tie for the most occurrences among integers 1 through n.

    Dynamic Programmingdigit-dpcombinatoricsmath
  • Dynamic ProgrammingMediumAuto-graded
    Compact RLE Coder: Decode a String and Re-encode Under Pattern Limit

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

    Dynamic Programmingstringsdynamic-programmingcompression
  • Dynamic ProgrammingHardAuto-graded
    Enumerate All Possible Tic-Tac-Toe Game Paths

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

    Dynamic Programmingrecursionmemoizationgame-theory
  • Dynamic ProgrammingMediumAuto-graded
    Longest Strictly Increasing Subsequence

    Tests understanding of dynamic programming optimization using binary search and greedy subsequence construction with the patience sorting technique.

    Dynamic Programmingbinary-searchsubsequencesgreedy
  • Dynamic ProgrammingMediumAuto-graded
    Worst Equity Drop, Best Trade, and Fewest Coins

    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.

    Dynamic Programmingarraysdynamic-programminggreedysingle-pass
  • Dynamic ProgrammingMediumAuto-graded
    Minimize Payment Transfers to Balance Group Accounts

    Tests backtracking with memoization to find the smallest number of payments needed to settle net balances across multiple participants.

    Dynamic Programmingbacktrackingmemoizationcombinatorial-search
  • Dynamic ProgrammingHardAuto-graded
    Expected Steps to Deplete Whole Pills from a Random Draw Process

    Tests modeling a stochastic process as a Markov chain and solving it with dynamic programming using conditional expectation.

    Dynamic Programmingprobabilityexpectationmarkov-chainrecurrence
  • Dynamic ProgrammingHardModel answer
    DAG Schedule Analysis and Windowed Checkpoint DP

    Compute critical-path latency and peak concurrency for a task DAG, then find minimum-cost checkpoint placement under a sliding-window coverage constraint.

    Dynamic Programmingdagtopological-sortsliding-windowdynamic-programming
  • Dynamic ProgrammingMediumAuto-graded
    Sum of All-One Squares in a Binary Grid

    Tests dynamic programming on 2D grids by computing the total count of square submatrices containing only ones.

    Dynamic Programmingdynamic-programmingmatrices2d-dp
  • Dynamic ProgrammingHardModel answer
    Two-Station Job Scheduling with Setups and a Downtime Window

    Assign and sequence three jobs across two parallel stations to minimize makespan, handling sequence-dependent changeovers, a precedence constraint, and a station blackout period.

    Dynamic Programmingschedulingcombinatorial-optimizationbranch-and-boundNP-hardness
  • Dynamic ProgrammingHardAuto-graded
    Build Arithmetic Expressions That Hit a Target Value

    Tests backtracking with incremental precedence-aware evaluation to enumerate all +/* expressions over a number sequence that sum to a given target.

    Dynamic Programmingbacktrackingrecursionoperator-precedence