You are given an integer array cost where cost[i] is the cost of stepping on the ith stair. You can climb either one or two steps at a time, and you may start from either index 0 or index 1.
Your task is to return the minimum cost to reach the top of the staircase (just beyond the last stair).
Input: cost = [10,15,20]
Output: 15
Explanation: Start at index 1, pay 15, and take two steps to reach the top.
Input: cost = [1,100,1,1,1,100,1,1,100,1]
Output: 6
Explanation: Stepping on indices 0, 2, 3, 4, 6, 7, and 9 gives a total cost of 6.
Input: cost = [0,0]
Output: 0
Explanation: Both stairs cost nothing, so the top is reached at zero cost.
Sign in to write, run, and submit your solution against the full test suite.