·
·
·
·
·
·
·
·
[0][1][2][3][4][5][6][7]
Tabulation (bottom-up)
▸1dp = array of size n2dp[0] = 0; dp[1] = 1 // base cases3for i in 2..n−1:4 // each subproblem solved once, then reused5 dp[i] = dp[i−1] + dp[i−2]6return dp[n−1]
state
- recurrencedp[i] = dp[i−1] + dp[i−2]