```
class Solution {
public:
bool canJump(vector<int>& nums) {
if(nums.size()==0||nums.size()==1)return true;
int i=nums.size()-2,j=1;
while(i!=0)
{
if(nums[i]<j)
{
j++;
}
else j=1;
i--;
}
if(nums[i]<j)return false;
return true;
}
};
```