Min Cost Climbing Stairs(sequence dp)
On a staircase, thei
-th step has some non-negative costcost[i]
assigned (0 indexed).
Once you pay the cost, you can either climb one or two steps. You need to find minimum cost to reach the top of the floor, and you can either start from the step with index 0, or the step with index 1.
Example 1:
Example 2:
Note:
分析
最后答案是 min(f[n - 1],f[n-2]) 大概是到最后一步的cost不算吧
Last updated
Was this helpful?