##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
You know recursion. Now see how memoization and tabulation turn exponential solutions into polynomial ones.
The power of optimization
LC 509 classic
Two starting points
Two calls
Direct translation
Explosion of calls
Same work repeated
O(2^n) disaster
Remember results
Test your understanding
The bridge
Caching results
Starting from the top
Adding memory
Three extra lines
O(n) now!
O(n) cost
LC 70 Fibonacci disguise
DP basics
Apply the pattern
The code
Knowledge check
Pattern recap
Building from ground up
Why called bottom-up
Iterative solution
Only keep what you need
Most efficient
When to use each
Your first cost problem
What dp[i] means
Choose cheaper path
Full solution
Read the problem
Negative numbers twist
Track min and max
Full solution
Knowledge check
LeetCode 91
One or two digits
Leading zeros
Ways to decode
Two choices
The code
What we learned