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.
17 STAGES Dynamic programming problems
☆☆☆☆☆ Clear 5 to finish this world.
EASY1:25Climbing Stairs
Dynamic programmingLC 70▶ START
MEDIUM1:25House Robber
Dynamic programmingLC 198▶ START
MEDIUM1:35House Robber II
Dynamic programmingLC 213▶ START
MEDIUM1:41Maximum Product Subarray
Dynamic programmingLC 152▶ START
MEDIUM1:40Decode Ways
Dynamic programmingLC 91▶ START
MEDIUM1:50Palindromic Substrings
Expand around centreLC 647▶ START
MEDIUM1:37Unique Paths
Dynamic programmingLC 62▶ START
MEDIUM1:37Coin Change
Dynamic programmingLC 322▶ START
MEDIUM1:40Perfect Squares
Dynamic programmingLC 279▶ START
MEDIUM1:41Partition Equal Subset Sum
Dynamic programmingLC 416▶ START
MEDIUM1:37Word Break
Dynamic programmingLC 139▶ START
MEDIUM1:40Longest Increasing Subsequence
Dynamic programmingLC 300▶ START
MEDIUM1:43Longest Common Subsequence
Dynamic programmingLC 1143▶ START
HARD1:34Distinct Subsequences
Dynamic programmingLC 115▶ START
HARD1:38Edit Distance
Dynamic programmingLC 72▶ START
HARD1:40Regular Expression Matching
Dynamic programmingLC 10▶ START
HARD1:35Longest Valid Parentheses
Dynamic programmingLC 32▶ START