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.
5 easy96 medium36 hard
Showing 31–60 of 137 results
Compute the exact probability of wealth hitting zero or below at any step during a finite sequence of random dice rolls.
Auto-gradeddynamic-programmingmath-bitsstatisticsChoose 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.
Auto-gradeddynamic-programmingpath-reconstructionpaint-houseDecide whether a string can become a palindrome after removing no more than k characters, testing interval dynamic programming and palindromic subsequence reasoning.
Auto-gradeddynamic-programmingpalindromestringssubsequenceFind the number of unique sequences of steps to reach a target using 1-unit steps or prime steps ending in digit 3.
Auto-gradeddynamic-programmingmathsievemodular-arithmeticMatch 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.
Auto-gradedbitmask-dpassignment-problemmanhattan-distanceEnumerate 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.
Auto-gradedrecursioninterval-dpexpression-treesmemoizationSolve the 0/1 knapsack problem with optimal item selection, optimize its space complexity, and extend the solution to bounded knapsacks efficiently.
Model answerdynamic-programmingarrayssliding-windowknapsackDecide 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.
Auto-gradedbitmask-dpgraphhamiltonian-pathsubsetsDecide whether a pattern containing '?' and '*' wildcards matches an entire string, testing dynamic programming or greedy two-pointer matching with backtracking.
Auto-gradedstringswildcard-matchingdynamic-programminggreedyFind the minimum combined count of paid and received coins to settle a precise target value using dynamic programming.
Auto-gradeddynamic-programmingarraysColor 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.
Model answerdynamic-programmingmemoizationspace-optimizationreconstructionCount 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.
Auto-gradedbitmask-dpcountingbacktrackingassignmentDetermine if a given string can be converted into a palindrome by removing at most k characters.
Auto-gradeddynamic-programmingstringsbit-manipulationFind all strings in a list that can be constructed by concatenating two or more smaller strings from the same list.
Model answerstringsdynamic-programmingtriehash-tableFind the maximum weight independent set for both a linear sequence and a binary tree network under non-adjacency constraints.
Auto-gradeddynamic-programmingtrees-graphsarraysCompute 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.
Auto-gradeddynamic-programminggridmatrixoptimizationFind the minimum combination of reusable containers to reach an exact target total volume, or return None if impossible.
Auto-gradeddynamic-programmingunbounded-knapsackbacktrackingFind 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.
Auto-gradedtrees-graphsdynamic-programmingarraysDecide whether a subsequence of positive integers, joined by + and * and evaluated strictly left to right, can equal a target, and produce one valid expression.
Model answerdynamic-programmingbacktrackingpruningreverse-searchCount valid grid paths composed of horizontal and vertical steps such that no direction is repeated three times in a row.
Auto-gradeddynamic-programminggridcombinatoricsmemoizationEnumerate 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.
Auto-gradedbacktrackingsubset-sumduplicatesenumerationDelete 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).
Model answerdynamic-programminglongest-increasing-subsequencebinary-searchsubsequenceDesign a deterministic per-tick controller for a thruster-driven drone navigating procedurally generated obstacle canyons using lookahead simulation.
Model answerdynamic-programminglookahead-searchsimulationmemoizationFind 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.
Auto-gradedkadanesubarraydynamic-programmingarraysFind the most disjoint three-card groups that each sum to 15, using memoized search over value counts because greedy choices can block better groupings.
Auto-gradedmemoizationrecursioncombinatoricsstate-compressionMaximize 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.
Auto-gradeddynamic-programmingarraysstock-tradingstate-machineCount 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.
Auto-gradeddigit-dpcountingrange-queriesmathFind 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.
Auto-gradeddynamic-programmingarrayssubarraytie-breakingFind 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.
Auto-gradeddynamic-programminggraphdfsmemoizationInterleave 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.
Auto-gradeddynamic-programmingstringsprefix-countsinterleaving