 All Problems
Min Cost Climbing Stairs
easy
dynamic programming
arrays
amazon
google
microsoft

You are given an integer array cost where cost[i] is the cost of the i-th step on a staircase. Once you pay, you can climb one or two steps. You can start from step 0 or 1. Return the minimum cost to reach the top (beyond the last step).

Example 1:

Input: 10 15 20
Output: 15

Example 2:

Input: 1 100 1 1 1 100 1 1 100 1
Output: 6

Input format: Space-separated costs.

Output format: Minimum cost integer.

Run to check your code against the sample cases, or submit to run every case