179. Min Cost Climbing Stairs

Given an array cost, where cost[i] is the cost of the i-th step. After paying, you may climb 1 or 2 steps. Return the minimum cost to reach the top (beyond the last step).
Example 1
Input: cost = [1,100,1,1,1,100,1,1,100,1]
Output: 6
Explanation: Avoid expensive steps by using cheap ones.
Example 2
Input: cost = [10,15,20]
Output: 15
Explanation: Minimum cost is 10 + 5 = 15 (from the 2nd step to the top).
arraysdynamic programmingeasy
JavaScript
Line 1, Char 1