Short and simple. Comment for explanation


#1

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

}
return 1;
}