Problem Description
Given an integer array A of length N. Where Ai is the cost of stepping on the ith stair.
From ith stair, you can go to i+1th or i+2th numbered stair.
Initially, you are at 1st stair find the minimum cost to reach Nth stair.
Problem Constraints
2 <= N <= 105
1 <= Ai <= 104
Input Format
The first and only argument is an integer array A.
Output Format
Return an integer.
Example Input
Input 1:
A = [1, 2, 1, 3]
Input 2:
A = [1, 2, 3, 4]
Example Output
Example Explanation
Explanation 1:
1 -> 3 -> 4
Explanation 2:
1 -> 2 -> 4
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified.
Still have a question? Checkout Sample Codes for more details.