[C++] Simple O(n) approach with iterative DP solution


#1
int Solution::canJump(vector<int> &A) {
    int n=A.size();
    if(n==1) return 1;
    bool dp[n]={};
    dp[n-1]=true;
    int last_occ=n-1;
    for(int i=n-2;i>=0;i--){
        if(A[i]+i>=last_occ) {
            dp[i]=true;
            last_occ=i;
        }
    }
    return dp[0];
}