解题思路:
贪婪
提交代码:
class Solution {
public int jump(int[] nums) {
int jumps=0,base=0,range=0;
for(int i=0;i<nums.length-1;i++) {
range=Math.max(range, i+nums[i]);
if(i==base) {
jumps++;
base=range;
}
}
return jumps;
}
}
运行结果: