WORLD 5
DYNAMIC PROGRAMMING
Remember the answers to smaller problems and build up: a staircase, a row of houses, a pile of coins, a rising run, two words.
STAGE 0 Dynamic programming tutorial
0:00 / 0:00
The move
Never solve the same subproblem twice. Either save each answer as you recurse (memoization) or fill a table from the smallest case up, building each cell once from the cells before it.
- Spot it
- The problem asks for a count, a best (min or max), or a yes or no, and the answer for n depends on answers for smaller sizes.
- Cost
- Number of states times the work per state: n states with constant work each is O(n) time.
22 STAGES
☆☆☆☆☆ Clear any 5 stages to beat this world, or all 22 for 100%.
EASY2:06Climbing Stairs
Dynamic programmingLC 70▶ START
MEDIUM2:01House Robber
Dynamic programmingLC 198▶ START
MEDIUM2:07House Robber II
Dynamic programmingLC 213▶ START
MEDIUM2:07Maximum Product Subarray
Dynamic programmingLC 152▶ START
MEDIUM2:09Best Time to Buy and Sell Stock with Cooldown
Dynamic programmingLC 309▶ START
MEDIUM2:07Best Time to Buy and Sell Stock with Transaction Fee
Dynamic programmingLC 714▶ START
MEDIUM1:55Decode Ways
Dynamic programmingLC 91▶ START
MEDIUM2:10Palindromic Substrings
Expand around centreLC 647▶ START
MEDIUM2:01Longest Palindromic Substring
Expand around centreLC 5▶ START
MEDIUM2:09Unique Paths
Dynamic programmingLC 62▶ START
MEDIUM2:09Maximal Square
Dynamic programmingLC 221▶ START
MEDIUM2:10Coin Change
Dynamic programmingLC 322▶ START
MEDIUM2:11Perfect Squares
Dynamic programmingLC 279▶ START
MEDIUM2:09Partition Equal Subset Sum
Dynamic programmingLC 416▶ START
MEDIUM2:00Word Break
Dynamic programmingLC 139▶ START
MEDIUM2:10Longest Increasing Subsequence
Dynamic programmingLC 300▶ START
MEDIUM2:02Longest Common Subsequence
Dynamic programmingLC 1143▶ START
HARD2:03Distinct Subsequences
Dynamic programmingLC 115▶ START
HARD2:12Maximum Profit in Job Scheduling
Dynamic programmingLC 1235▶ START
HARD2:08Edit Distance
Dynamic programmingLC 72▶ START
HARD2:06Regular Expression Matching
Dynamic programmingLC 10▶ START
HARD2:10Longest Valid Parentheses
Dynamic programmingLC 32▶ START