class Solution {
public:
int jump(vector<int>& nums) {
if (nums.size() <= 1){
return 0;
}
int firstNum = nums[0];
if (firstNum == 0){
return 0;
}
int scope = firstNum;
int step = 0;
int from = 1;
while (scope < nums.size() - 1){
int currentScope = scope;
for (int i = from; i <= scope; i++){
if (currentScope < i + nums[i])
currentScope = i + nums[i];
}
step++;
from = scope + 1;
scope = currentScope;
}
return step + 1;
}
};