This a DP solution, and the idea is to save the maximum jump length every time, if the maximum length be zero, than return false.

```
class Solution {
public:
bool canJump(std::vector<int> &nums) {
int maxJumpNow = 0, len = static_cast<int>(nums.size());
for (int i = 0; i < len - 1 && maxJumpNow < len - i; ++i)
if (!(maxJumpNow = std::max(maxJumpNow - 1, nums[i])))
return false;
return true;
}
};
```