Simple C++ solution without DP IN O(N) time and O(1) space


#1

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

return 1;

}