My recursive solution time limited


  • -1
    N

    I just want to finish it with recursive solution, but failed

    public boolean canJump(int[] A) {
        return f(A,0);
    }
    public boolean f(int[] a, int curr){
        if(a[curr]+curr>=a.length-1)
        return true;
        for(int i=a[curr];i>0;i--){
            boolean h=f(a,curr+i);
            if(h==true)
            return true;
        }
        return false;
    }

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.