C++ TC = O(N) and SC = O(1) Greedy Solution


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

}