Min Cost Climbing Stairs
Easy
Topics
Given an array cost where cost[i] is the cost of step i, you can climb 1 or 2 steps and start from index 0 or 1. Return the minimum cost to reach the top (just past the last step).
Example 1
Input: cost = [10,15,20] Output: 15
Example 2
Input: cost = [1,100,1,1,1,100,1,1,100,1] Output: 6
Constraints
- 2 <= cost.length <= 1000
- 0 <= cost[i] <= 999
Run ⌘' · Submit ⌘⏎