https://leetcode-cn.com/problems/jump-game/
class Solution {
public boolean canJump(int[] nums) {
if (nums.length==1){
return true;
}
if(nums[0]==0){
return false;
}
int max=nums[0];
for (int i=0;i<max;i++){
int step=i+nums[i];
while (true){
if (step>=nums.length-1){
return true;
}else {
if (step>max){
max=step;
}
if(nums[step]==0){
break;
}
step=step+nums[step];
}
}
}
return false;
}
}