Dynamic programming problems in Python
Build answers from the answers to smaller cases: dynamic programming problems in Python, with tests.
Beginner
Intermediate
- 71. Maximum Subarray SumThe best unbroken run in a list of ups and downs65 XP10 min
- 82. House RobberThe most loot from a street without setting off an alarm70 XP12 min
- 90. Grid Paths with WallsCount the routes across a grid when some squares are blocked75 XP14 min
- 106. Fewest CoinsThe smallest handful of coins that pays an exact amount85 XP15 min
- 111. Ways to Make ChangeHow many different handfuls of coins pay the bill exactly?85 XP15 min
- 115. Word BreakCan this run-together text be split into real words?90 XP18 min
- 279. Cheapest Path Down a TriangleSlide down a pyramid of numbers, paying for every stone you touch65 XP12 min
- 303. Houses in a CircleA thief, a ring of houses and alarms that link every pair of neighbours70 XP12 min
- 330. Equal-Sum HalvesCan two friends share the parcels so both carry the same weight?80 XP15 min
- 340. Plus or MinusA plus or a minus in front of every number: how many ways hit the total?85 XP16 min
Advanced
- 130. Longest Increasing SubsequenceThe longest climb hidden inside a jumbled list120 XP22 min
- 135. Longest Common SubsequenceHow much do two strings have in common, in order?125 XP22 min
- 141. Decode WaysHow many messages could this string of digits spell?130 XP25 min
- 156. Pack the KnapsackThe most valuable load a backpack can carry140 XP25 min
- 367. Longest Palindromic SubsequenceCross out letters until the word reads the same both ways130 XP25 min
- 375. Interleaving StringsTwo strings woven together: could this string be the result?135 XP25 min
- 387. Longest Balanced Bracket RunThe longest stretch where every bracket has its partner140 XP25 min
- 398. Health for the DungeonHow much health does the knight need to survive the dungeon?145 XP30 min
- 403. Best Profit With K TradesA limited number of trades: when should you buy, and when sell?150 XP30 min
- 408. Fewest Palindrome CutsSlice a word into mirror-image pieces with as few cuts as you can150 XP30 min
- 413. Most Profitable JobsPick the gigs that pay the most when no two can overlap150 XP30 min
Expert
- 174. Edit DistanceThe fewest typo fixes that turn one word into another200 XP30 min
- 181. Distinct SubsequencesHow many ways does a word hide inside a longer string?220 XP40 min
- 191. Egg DropHow few drops does it take to find the safe floor?250 XP45 min
- 197. Regular Expression MatchingDoes the whole string fit a pattern of dots and stars?260 XP50 min
- 198. Burst BalloonsPop the balloons in the order that scores the most points280 XP55 min
- 434. Frog CrossingStone by stone across the river, each jump a little longer or shorter200 XP35 min
- 462. The Delivery TourOne van, every stop once, then back home: the shortest possible round230 XP45 min
- 480. The Strange PrinterA printer that paints runs of one letter at a time: how few passes?250 XP45 min
- 484. Cherry Picking Round TripDown to the far corner and back again: how many cherries can you pick?260 XP50 min
- 494. Shortest SuperstringSqueeze every word into one string, overlapping wherever you can270 XP55 min
- 497. Cheapest Way to Merge PilesSquash a row of sand piles into one, a few at a time, for the least effort280 XP55 min
- 500. Distinct Palindromic SubsequencesHow many different mirror-image strands hide inside a strand of DNA?290 XP60 min
Other topics
- Python Basics
- Strings
- Lists
- Dictionaries and sets
- Loops
- Functions
- Math
- Sorting and searching
- Two pointers
- Sliding window
- Stacks and queues
- Recursion and backtracking
- Greedy
- Graphs
- Trees
- Bit manipulation
- Classes
- Iterators and generators
- Parsing
- Simulation
- Python idioms
- Regular expressions
- Codes and ciphers
- Working with data
- Grids and matrices
- Geometry
- Games and puzzles
- Heaps
- Data structures
Or see every challenge, with study plans, today's challenge and duels.