Min Cost Climbing Stairs
EasyDynamic Programming
Decode it first. Clues, constraints, pattern and plan before any code.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.
cost = [10, 15, 20] → 15 (start on 1, jump 2 to the top)
cost = [1, 100, 1, 1, 1, 100, 1, 1, 100, 1] → 6Constraints
2 <= cost.length <= 10000 <= cost[i] <= 999