Accepted elegant Java solution, but it is so slow, who can tell me the time complexity


  • 0
    W
    public int jump(int[] nums) {
        return jump(nums, nums.length - 1);
    }
    
    private int jump(int[] nums, int end){
        int last = end;
        for(int i = end - 1; i >= 0; i--)
            if(nums[i] >= end - i)
                last = i;
        return last == end ? 0 : 1 + jump(nums, last);
    }

Log in to reply
 

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