Problem
cost[i] is the price of standing on step i. You may start on step 0 or step 1. After paying for a step, you climb 1 or 2 steps. The top is just past the last step. Return the cheapest total cost to reach the top.
Example 1
- Input
- cost = [10, 15, 20]
- Output
- 15
- Why
- start on 1, jump 2 to the top
Example 2
- Input
- cost = [1, 100, 1, 1, 1, 100, 1, 1, 100, 1]
- Output
- 6
Constraints
2 <= cost.length <= 10000 <= cost[i] <= 999