贪心算法:
class Solution {
public boolean canJump(int[] nums) {
int leftBorder = 0;
for (int i = 0; i <nums.length; i++) {
if(i<=leftBorder){
leftBorder=Math.max(leftBorder,i+nums[i]);
}
if(leftBorder>=nums.length-1){
return true;
}
}
return false;
}
}