Dynamic Programming LeetCode Problems: All 481,
With Python Solutions

Every problem in this library that LeetCode tags Dynamic Programming. 416 of them carry a complete Python solution, a worked example and the time and space complexity of the approach.

Easy
12
Medium
243
Hard
226
1 pattern

How Dynamic Programming problems are solved

A tag names the subject, not the method. These pattern hubs cover the techniques that actually solve Dynamic Programming problems — each one explains the approach, gives a Python template and states its complexity.

Eyes only

When the Dynamic Programming problem arrives live.

In the live round, Stealth Interview reads the problem off your screen, returns a working solution with a step-by-step explanation and its time and space complexity, and transcribes what the interviewer says. It's a desktop app for macOS and Windows, invisible to screen sharing.

Dynamic Programming problems by difficulty

Showing the first 200 of 481 problems. Problems with a complete Python solution are listed first, then by ascending problem number.

Easy (10)

Easy problems
No.Problem
0070Climbing Stairs
0118Pascal's Triangle
0119Pascal's Triangle II
0121Best Time to Buy and Sell Stock
0338Counting Bits
0392Is Subsequence
0509Fibonacci Number
0746Min Cost Climbing Stairs
1025Divisor Game
1137N-th Tribonacci Number

Medium (111)

Medium problems
No.Problem
0005Longest Palindromic Substring
0022Generate Parentheses
0045Jump Game II
0053Maximum Subarray
0055Jump Game
0062Unique Paths
0063Unique Paths II
0064Minimum Path Sum
0072Edit Distance
0091Decode Ways
0095Unique Binary Search Trees II
0096Unique Binary Search Trees
0097Interleaving String
0120Triangle
0122Best Time to Buy and Sell Stock II
0131Palindrome Partitioning
0139Word Break
0152Maximum Product Subarray
0198House Robber
0213House Robber II
0221Maximal Square
0241Different Ways to Add Parentheses
0264Ugly Number II
0279Perfect Squares
0300Longest Increasing Subsequence
0309Best Time to Buy and Sell Stock with Cooldown
0313Super Ugly Number
0322Coin Change
0337House Robber III
0343Integer Break
0357Count Numbers with Unique Digits
0368Largest Divisible Subset
0375Guess Number Higher or Lower II
0376Wiggle Subsequence
0377Combination Sum IV
0396Rotate Function
0397Integer Replacement
0413Arithmetic Slices
0416Partition Equal Subset Sum
0435Non-overlapping Intervals
0464Can I Win
0467Unique Substrings in Wraparound String
0473Matchsticks to Square
0474Ones and Zeroes
0486Predict the Winner
0494Target Sum
0516Longest Palindromic Subsequence
0518Coin Change II
0526Beautiful Arrangement
054201 Matrix
0553Optimal Division
0576Out of Boundary Paths
0583Delete Operation for Two Strings
0638Shopping Offers
0646Maximum Length of Pair Chain
0647Palindromic Substrings
06502 Keys Keyboard
0673Number of Longest Increasing Subsequence
0678Valid Parenthesis String
0688Knight Probability in Chessboard
0698Partition to K Equal Sum Subsets
0712Minimum ASCII Delete Sum for Two Strings
0714Best Time to Buy and Sell Stock with Transaction Fee
0718Maximum Length of Repeated Subarray
0740Delete and Earn
0764Largest Plus Sign
0787Cheapest Flights Within K Stops
0788Rotated Digits
0790Domino and Tromino Tiling
0792Number of Matching Subsequences
0799Champagne Tower
0808Soup Servings
0813Largest Sum of Averages
0823Binary Trees With Factors
0837New 21 Game
0838Push Dominoes
0845Longest Mountain in Array
0873Length of Longest Fibonacci Subsequence
0877Stone Game
0894All Possible Full Binary Trees
0898Bitwise ORs of Subarrays
0907Sum of Subarray Minimums
0918Maximum Sum Circular Subarray
0926Flip String to Monotone Increasing
0931Minimum Falling Path Sum
0935Knight Dialer
0978Longest Turbulent Subarray
0983Minimum Cost For Tickets
1014Best Sightseeing Pair
1024Video Stitching
1027Longest Arithmetic Subsequence
1031Maximum Sum of Two Non-Overlapping Subarrays
1035Uncrossed Lines
1039Minimum Score Triangulation of Polygon
1043Partition Array for Maximum Sum
1048Longest String Chain
1049Last Stone Weight II
1105Filling Bookcase Shelves
1130Minimum Cost Tree From Leaf Values
1139Largest 1-Bordered Square
1140Stone Game II
1143Longest Common Subsequence
1155Number of Dice Rolls With Target Sum
1162As Far from Land as Possible
1186Maximum Subarray Sum with One Deletion
1191K-Concatenation Maximum Sum
1218Longest Arithmetic Subsequence of Given Difference
1227Airplane Seat Assignment Probability
1262Greatest Sum Divisible by Three
1277Count Square Submatrices with All Ones
1334Find the City With the Smallest Number of Neighbors at a Threshold Distance

Hard (79)

Hard problems
No.Problem
0010Regular Expression Matching
0032Longest Valid Parentheses
0042Trapping Rain Water
0044Wildcard Matching
0085Maximal Rectangle
0087Scramble String
0115Distinct Subsequences
0123Best Time to Buy and Sell Stock III
0124Binary Tree Maximum Path Sum
0132Palindrome Partitioning II
0140Word Break II
0174Dungeon Game
0188Best Time to Buy and Sell Stock IV
0233Number of Digit One
0312Burst Balloons
0329Longest Increasing Path in a Matrix
0354Russian Doll Envelopes
0403Frog Jump
0410Split Array Largest Sum
0446Arithmetic Slices II - Subsequence
0458Poor Pigs
0466Count The Repetitions
0472Concatenated Words
0488Zuma Game
0514Freedom Trail
0546Remove Boxes
0552Student Attendance Record II
0600Non-negative Integers without Consecutive Ones
0629K Inverse Pairs Array
0639Decode Ways II
0664Strange Printer
0689Maximum Sum of 3 Non-Overlapping Subarrays
0691Stickers to Spell Word
0730Count Different Palindromic Subsequences
0741Cherry Pickup
0773Sliding Puzzle
0801Minimum Swaps To Make Sequences Increasing
0805Split Array With Same Average
0818Race Car
0828Count Unique Characters of All Substrings of a Given String
0834Sum of Distances in Tree
0847Shortest Path Visiting All Nodes
0871Minimum Number of Refueling Stops
0879Profitable Schemes
0887Super Egg Drop
0902Numbers At Most N Given Digit Set
0903Valid Permutations for DI Sequence
0913Cat and Mouse
0920Number of Music Playlists
0940Distinct Subsequences II
0943Find the Shortest Superstring
0956Tallest Billboard
0960Delete Columns to Make Sorted III
0964Least Operators to Express Number
0968Binary Tree Cameras
0975Odd Even Jump
0996Number of Squareful Arrays
1000Minimum Cost to Merge Stones
1012Numbers With Repeated Digits
1092Shortest Common Supersequence
1125Smallest Sufficient Team
1147Longest Chunked Palindrome Decomposition
1187Make Array Strictly Increasing
1220Count Vowels Permutation
1223Dice Roll Simulation
1235Maximum Profit in Job Scheduling
1255Maximum Score Words Formed by Letters
1269Number of Ways to Stay in the Same Place After Some Steps
1278Palindrome Partitioning III
1289Minimum Falling Path Sum II
1301Number of Paths with Max Score
1312Minimum Insertion Steps to Make a String Palindrome
1320Minimum Distance to Type a Word Using Two Fingers
1326Minimum Number of Taps to Open to Water a Garden
1335Minimum Difficulty of a Job Schedule
1340Jump Game V
1349Maximum Students Taking Exam
1359Count All Valid Pickup and Delivery Options
1363Largest Multiple of Three