https://leetcode.com/problems/jump-game-ii/?tab=Description
找到最小跳到末尾的步数
从start开始跳最远能跳到end,内层扫start~end,找到这里面能到的最远位置
public class Solution {
public int jump(int[] nums) {
if (nums == null || nums.length == 0) {
return 0;
}
int start = 0;
int end = 0;
int jump = 0;
while (end < nums.length - 1) {
int far = end;
jump++;
for (int i = start; i <= end; i++) {
if ((nums[i] + i) > far) {
far = nums[i] + i;
}
}
start = end;
end = far;
}
return jump;
}
}