Getting mle...o(1) memory is only allocated


#1

Comment body goes here.
int findans(vectorv,int pos,int &m)
{
if(pos>=v.size())
return 0;
if(pos==v.size()-1)
return 1;

for(int i=1;i<=v[pos];i++)
{
    if(pos+i >m){
   int k= findans(v,pos+i,m);
   if(k==1)
    return 1;
    if(pos+i > m)
      m=pos+i;
    }
}
return 0;

}
int Solution::canJump(vector &A) {
int m=INT_MIN;
if(findans(A,0,m))
return 1;
else
return 0;
}


#2

its due to recursion. try to do it without recursion.