Problem Statement | |||||||||||||
There is an ascending staircase where each step has a distinct absolute height above the floor given in inches. You must climb the staircase using a series of moves. On each move, you must do one of the following:
You are given a int[] stairs containing the heights of the steps from bottom to top. You are initially on the bottom step. Return the minimal number of moves necessary to reach the top step. Return -1 if it is impossible. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Constraints | |||||||||||||
- | stairs will contain between 2 and 50 elements, inclusive. | ||||||||||||
- | The first element of stairs will be 0. | ||||||||||||
- | Elements of stairs will be in increasing order. | ||||||||||||
- | Each element of stairs will be between 0 and 109, inclusive. | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
| |||||||||||||
3) | |||||||||||||
| |||||||||||||
4) | |||||||||||||
| |||||||||||||
5) | |||||||||||||
|