Ladder Approach, Easy O(n) solution


#1
int Solution::canJump(vector<int> &A) {
    int n = A.size();
    if(n <= 1) return 1;
    
    
    int ladder = A[0];
    
    for(int i = 1; i < n; i++) {
        if(i > ladder) return 0;
        
        ladder = max(ladder, i + A[i]);
        
        if(ladder >= n-1) return 1;
    }
    
    
    return 0;
}