Levenshtein Distance
Implement the classic Levenshtein distance algorithm to measure string similarity.
Kadane Variant: Maximum Product Subarray
Implement max_product_subarray(nums) that returns the maximum product of any contiguous subarray.
Bell number
Implement a function to compute the Bell number B(n) using dynamic programming.
Longest Palindromic Subsequence
Compute the length of the longest palindromic subsequence in a given string.
0/1 Knapsack
Implement the classic 0/1 Knapsack dynamic programming solution to maximize value under a weight capacity.
Target Sum Subsets
Write a function that counts the number of subsets of a list of positive integers that sum exactly to a target.
Coin Change Minimum
Given coin denominations and a target amount, compute the minimum number of coins needed or -1 if impossible.
Perfect Squares Sum
Given a positive integer n, return the least number of perfect squares (e.g., 1, 4, 9, 16, ...) that sum to n.
Word Break DP
Implement a function to check if a string can be segmented into space-separated dictionary words.
Buy Sell Stock with Cooldown (DP)
Given daily stock prices, compute the maximum profit you can achieve if you must wait one day after selling before buying again.
Longest Arithmetic Subsequence
Given a list of integers, return the length of the longest arithmetic subsequence (constant difference) within it.
Shortest Common Supersequence
Given two strings, return any shortest supersequence that contains both as subsequences.
Interleaving string
Given three strings s1, s2, and s3, check if s3 is formed by interleaving s1 and s2 while preserving the order of each input string.
Matrix Chain Multiplication
Given a list of matrix dimensions, compute the minimum multiplication cost using dynamic programming.
Subset Sum Exists
Given a list of positive integers and a target sum, return whether some subset adds up exactly to the target.
Showing 1–15 of 15 challenges · medium · Dynamic Programming
Dynamic Programming — Python coding challenges
What you will find here
This page lists dynamic programming challenges — real Python problems you solve in the browser IDE with instant test feedback. Each challenge includes a clear brief, starter code, and automated checks.
Challenges vs tutorials and quizzes
Challenges test what you can build under constraints. For guided teaching, use our Python tutorials. For quick checks, try quizzes or copy snippets from code samples.