Data structures and algorithms · Dynamic programming
Dynamic programming
Solve each small problem once, and keep the answer. · 12 minutes
Predict first
How many times is fib(1) called while computing fib(20)?
1def fib(n):2if n <= 1:3return n4return fib(n - 1) + fib(n - 2)