KatInterview

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

Dynamic Programming Interview Problems

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

5966
Problems
2209
Auto-graded
15
Topics
271
Added today

Showing 31–60 of 137 results

  • Dynamic ProgrammingEasyAuto-graded
    Bankrupt Risk in Dice Game

    Compute the exact probability of wealth hitting zero or below at any step during a finite sequence of random dice rolls.

    Dynamic Programmingdynamic-programmingmath-bitsstatistics
  • Dynamic ProgrammingMediumAuto-graded
    Cheapest Daily Ticket Plan Without Back-to-Back Repeats

    Choose one of three item types each day with no type repeated on adjacent days, minimizing total cost and returning the unique optimal sequence of choices.

    Dynamic Programmingdynamic-programmingpath-reconstructionpaint-house
  • Dynamic ProgrammingHardAuto-graded
    Trim Letters to Reach a Mirror String Within a Budget

    Decide whether a string can become a palindrome after removing no more than k characters, testing interval dynamic programming and palindromic subsequence reasoning.

    Dynamic Programmingdynamic-programmingpalindromestringssubsequence
  • Dynamic ProgrammingMediumAuto-graded
    Count Step Sequences with Custom Prime Jumps

    Find the number of unique sequences of steps to reach a target using 1-unit steps or prime steps ending in digit 3.

    Dynamic Programmingdynamic-programmingmathsievemodular-arithmetic
  • Dynamic ProgrammingMediumAuto-graded
    Pair Workers With Distinct Stations at Minimum Grid Distance

    Match each point in one list to a different point in a larger list so the total Manhattan distance is minimal, which suits a bitmask DP given the small limits.

    Dynamic Programmingbitmask-dpassignment-problemmanhattan-distance
  • Dynamic ProgrammingMediumAuto-graded
    Smallest Fully Bracketed Arithmetic Expression Hitting a Target

    Enumerate all operator and bracket choices over an ordered list of numbers and return the ASCII-smallest canonical expression that evaluates to the target, or an empty string.

    Dynamic Programmingrecursioninterval-dpexpression-treesmemoization
  • Dynamic ProgrammingMediumModel answer
    0/1 to Bounded Knapsack Optimization and Traceback

    Solve the 0/1 knapsack problem with optimal item selection, optimize its space complexity, and extend the solution to bounded knapsacks efficiently.

    Dynamic Programmingdynamic-programmingarrayssliding-windowknapsack
  • Dynamic ProgrammingHardAuto-graded
    Visit Every Node Exactly Once: Path Existence in a Small Graph

    Decide whether an undirected graph of at most 20 vertices has a simple path through every vertex, which is best solved with a bitmask DP over visited subsets.

    Dynamic Programmingbitmask-dpgraphhamiltonian-pathsubsets
  • Dynamic ProgrammingMediumAuto-graded
    Full-String Matching With Single and Multi Character Wildcards

    Decide whether a pattern containing '?' and '*' wildcards matches an entire string, testing dynamic programming or greedy two-pointer matching with backtracking.

    Dynamic Programmingstringswildcard-matchingdynamic-programminggreedy
  • Dynamic ProgrammingHardAuto-graded
    Minimal Coin Exchange with Overpayment

    Find the minimum combined count of paid and received coins to settle a precise target value using dynamic programming.

    Dynamic Programmingdynamic-programmingarrays
  • Dynamic ProgrammingMediumModel answer
    Cheapest Fence Painting With No Matching Neighbors

    Color a row of posts from a cost table so no two neighbors match, minimizing total cost, using memoized recursion and a space-optimized bottom-up DP, and recover one optimal coloring.

    Dynamic Programmingdynamic-programmingmemoizationspace-optimizationreconstruction
  • Dynamic ProgrammingHardAuto-graded
    Count and Score Conflict-Free Cap Distributions

    Count the ways to give each person a distinct acceptable item and find the best total value, using a bitmask DP over people or bounded backtracking.

    Dynamic Programmingbitmask-dpcountingbacktrackingassignment
  • Dynamic ProgrammingMediumAuto-graded
    Check Palindrome Transformation Within K Removals

    Determine if a given string can be converted into a palindrome by removing at most k characters.

    Dynamic Programmingdynamic-programmingstringsbit-manipulation
  • Dynamic ProgrammingHardModel answer
    Identify Compound Words in a Dictionary

    Find all strings in a list that can be constructed by concatenating two or more smaller strings from the same list.

    Dynamic Programmingstringsdynamic-programmingtriehash-table
  • Dynamic ProgrammingMediumAuto-graded
    Maximum Independent Set on Line and Binary Tree

    Find the maximum weight independent set for both a linear sequence and a binary tree network under non-adjacency constraints.

    Dynamic Programmingdynamic-programmingtrees-graphsarrays
  • Dynamic ProgrammingMediumAuto-graded
    Cheapest Right-and-Down Route Across a Cost Map

    Compute the minimum total cost of a route through a rectangular cost grid using only right and down moves, which tests 2D dynamic programming with a space optimization.

    Dynamic Programmingdynamic-programminggridmatrixoptimization
  • Dynamic ProgrammingMediumAuto-graded
    Minimum Containers for Target Volume

    Find the minimum combination of reusable containers to reach an exact target total volume, or return None if impossible.

    Dynamic Programmingdynamic-programmingunbounded-knapsackbacktracking
  • Dynamic ProgrammingHardAuto-graded
    Maximum Non-Adjacent Node Value Sum in Binary Tree

    Find the maximum total node sum from a binary tree represented as a level-order list such that no two selected nodes share a parent-child edge.

    Dynamic Programmingtrees-graphsdynamic-programmingarrays
  • Dynamic ProgrammingMediumModel answer
    Left-to-Right Plus/Times Expression from a Subsequence

    Decide whether a subsequence of positive integers, joined by + and * and evaluated strictly left to right, can equal a target, and produce one valid expression.

    Dynamic Programmingdynamic-programmingbacktrackingpruningreverse-search
  • Dynamic ProgrammingMediumAuto-graded
    Count Grid Walkways Without Three Consecutive Steps

    Count valid grid paths composed of horizontal and vertical steps such that no direction is repeated three times in a row.

    Dynamic Programmingdynamic-programminggridcombinatoricsmemoization
  • Dynamic ProgrammingMediumAuto-graded
    Distinct Sub-Multisets That Hit a Target Sum

    Enumerate every distinct selection of list elements, each used at most once, that sums to a target, with negatives, zeros and duplicates allowed. Tests backtracking over value counts.

    Dynamic Programmingbacktrackingsubset-sumduplicatesenumeration
  • Dynamic ProgrammingHardModel answer
    Best Self-Matching Count After Removing Array Elements

    Delete any elements from an array so the most remaining values equal their new 1-based position. Reduce it to a longest-chain problem solved in O(n log n).

    Dynamic Programmingdynamic-programminglongest-increasing-subsequencebinary-searchsubsequence
  • Dynamic ProgrammingMediumModel answer
    Autonomous Drone Navigation in Dynamic Canyons

    Design a deterministic per-tick controller for a thruster-driven drone navigating procedurally generated obstacle canyons using lookahead simulation.

    Dynamic Programmingdynamic-programminglookahead-searchsimulationmemoization
  • Dynamic ProgrammingMediumAuto-graded
    Highest-Yield Consecutive Stretch in a Profit Log

    Find the largest total achievable by a non-empty run of adjacent integers, handling all-negative inputs and large sums, in one pass with constant extra space.

    Dynamic Programmingkadanesubarraydynamic-programmingarrays
  • Dynamic ProgrammingMediumAuto-graded
    Maximum Disjoint Triples Summing to 15

    Find the most disjoint three-card groups that each sum to 15, using memoized search over value counts because greedy choices can block better groupings.

    Dynamic Programmingmemoizationrecursioncombinatoricsstate-compression
  • Dynamic ProgrammingHardAuto-graded
    Best Profit from a Capped Number of Round-Trip Trades

    Maximize profit from daily share prices using at most k non-overlapping buy-then-sell trades, testing state-based dynamic programming and handling a trade limit that never binds.

    Dynamic Programmingdynamic-programmingarraysstock-tradingstate-machine
  • Dynamic ProgrammingMediumAuto-graded
    Most Populous Digit-Sum Group in a Number Range

    Count integers in a huge range grouped by digit sum and return the largest group size, which needs a digit DP with prefix-count subtraction rather than enumeration.

    Dynamic Programmingdigit-dpcountingrange-queriesmath
  • Dynamic ProgrammingMediumAuto-graded
    Longest Shared Run Between Two Integer Lists

    Find the longest block of consecutive values common to two integer lists, and report its length and the smallest pair of start positions, using dynamic programming over suffix matches.

    Dynamic Programmingdynamic-programmingarrayssubarraytie-breaking
  • Dynamic ProgrammingMediumAuto-graded
    Tallest Staircase Walk Across a Number Board

    Find the longest chain of orthogonally adjacent cells with strictly increasing values in a 2D grid, testing DAG longest-path DP, memoization, and avoiding deep recursion.

    Dynamic Programmingdynamic-programminggraphdfsmemoization
  • Dynamic ProgrammingHardAuto-graded
    Minimum Disorder When Interleaving Two Job Queues

    Interleave two letter strings while keeping each one's order, minimizing out-of-order pairs; tests 2D prefix DP with O(1) transition costs from alphabet-count tables.

    Dynamic Programmingdynamic-programmingstringsprefix-countsinterleaving