Min Cost Climbing Stairs
cost[i] is the fee for stepping on stair i. Start at stair 0 or 1, then climb one or two stairs each move. Return the minimum fee to reach beyond the last stair.
Example 1
cost = [4,9,2,5]6Explanation
Pay 4 at stair 0, jump to stair 2 for 2, then beyond the end, totaling 6.
Example 2
cost = [10,1]1Explanation
Start at stair 1 for cost 1 and jump beyond the final stair.
Example 3
cost = [0,0,0]0Explanation
All fees are zero, so every valid route costs zero.
Constraints
- 2 <= len(cost) <= 1000
- Fees are 0..999
Function contract
minCostClimbingStairsArguments: jsonSolutionRuns on your device
Loading draft…
Run: 3 examples; Submit: 35 cases, on your device.
[4,9,2,5]