746. Min Cost Climbing Stairs

Practice Min Cost Climbing Stairs for free on NudgeCode: Easy, Dynamic Programming pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.

Step i of a staircase costs cost[i] to stand on. You may start on step 0 or step 1, and from any step you may climb 1 or 2 steps. The top is just past the last step. Return the smallest total cost to reach the top.

Example

cost = [10,15,20]                    ->  15   (start on step 1, climb 2)
cost = [1,100,1,1,1,100,1,1,100,1]   ->  6

Constraints