6ms Java O(logn) solution 14.4% what to improve?


  • 0
    F
        return findindex(nums,0,nums.length-1,target);}
    public int findindex(int[] nums,int low,int high,int target){
        if(low==high-1||low==high){
            if(target<=nums[high]&&target>nums[low])
            return high;
            if(target>nums[high])
            return high+1;
            else return low;
        }
        int index = low+(high-low)/2;
        if (target == nums[index])
        return index;
        if(target < nums[index]) 
        return findindex(nums,low,index,target);
        else 
        return findindex(nums,index,high,target);
        
    }
    

    }


Log in to reply
 

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