Min Cost Climbing Stairs
Given an array cost where cost[i] is the price to step on stair i, you may climb one or two stairs each move and may start at stair 0 or stair 1. Return the minimum total cost to reach the top, which is one step beyond the last stair.
Open official problem prompt ↗Compute the least total toll to climb past the last stair, given you pay a stair's toll only when you step on it and may hop one or two stairs at a time.
Like a toll road where each booth (stair) charges a fee and you may skip at most one booth per move; you start free at either of the first two booths and want the cheapest route off the end.
- Input
- cost = [10, 15, 20]
- Output
- 15
- Why
- Start at index 1 (pay 15) and take two steps to reach the top; total 15, cheaper than starting at index 0.
2 <= cost.length <= 10000 <= cost[i] <= 999