题目:
题解:
int jump(int* nums, int numsSize) {
int steps = 0;
int maxReach = 0;
int lastJump = 0;
for (int i = 0; i < numsSize - 1; ++i) {
maxReach = (i + nums[i] > maxReach) ? i + nums[i] : maxReach;
if (i == lastJump) {
lastJump = maxReach;
++steps;
if (maxReach >= numsSize - 1) {
return steps;
}
}
}
return 0;
}