Easy to understand java solution (binarySearch)


  • 0
    C
    public int findMin(int[] nums) {
        int start=0;
        int end=nums.length-1;
        int mid;
        while(start<end){
            mid=(start+end)/2;
            if(nums[mid]>nums[end]){
                start=mid+1;
            }
            if(nums[mid]<nums[end]){
                end=mid;
            }
        }
        return nums[end];
    }

Log in to reply
 

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