Kadane Variant: Maximum Product Subarray
Implement max_product_subarray(nums) that returns the maximum product of any contiguous subarray.
Climbing Stairs
Implement a function that returns the number of distinct ways to climb n stairs using steps of 1 or 2.
House Robber
Given a list of house values, return the maximum sum you can rob without robbing two adjacent houses.
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.
Palindrome Partitioning Minimum Cuts
Given a string, return the minimum number of cuts needed such that every substring in the partition is a palindrome.
Longest Arithmetic Subsequence
Given a list of integers, return the length of the longest arithmetic subsequence (constant difference) within it.
Shortest Unsorted Continuous Subarray
Given an array of integers, return the length of the shortest contiguous subarray whose sorting makes the whole array sorted.
Ugly Number II
Given an integer n, return the nth ugly number using an efficient dynamic programming approach.
Shortest Common Supersequence
Given two strings, return any shortest supersequence that contains both as subsequences.
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–10 of 10 challenges · 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.