You are given an integer array cost where cost[i] is the cost of the i-th step on a staircase. Once you pay the cost, you can either climb one or two steps. You can either start from the step with index 0, or the step with index 1. Return the minimum cost to reach the top of the floor (just past the last step).
Example 1
Input: cost = [10,15,20]
Output: 15
Explanation: Start at index 1, pay 15, and climb two steps straight to the top. Starting at index 0 would cost at least 10 + 20 = 30.
Example 2
Input: cost = [1,100,1,1,1,100,1,1,100,1]
Output: 6
Explanation: Start at index 0 and step only on the 1s: indices 0, 2, 4, 6, 7 and 9, paying 1 each time. That totals 6 and avoids every 100.
Example 3
Input: cost = [0,0]
Output: 0
Explanation: Both steps are free, so the top can be reached for 0.
The cheapest way to stand on step i is its own cost plus the cheaper of the two steps you could have jumped from (i-1 or i-2).
Run checks all cases above. Submit evaluates all test cases.