```
public class Solution {
public boolean canJump(int[] nums) {
if (nums == null || nums.length == 0) return true;
int len = nums.length, j = 0, last = len;
boolean []dp = new boolean[len + 1];
dp[len] = true;
for (int i = len - 2; i >= 0; i--) {
if (dp[i+2] && nums[i] > 0) {
dp[i+1] = true;
last = i + 1;
}
else if (!dp[i+2]) {
if (last - (i + 1) <= nums[i]) {
dp[i+1] = true;
last = i + 1;
}
}
}
return dp[1];
}
}
```