AC simple java solution


  • 0
    D
    public int findMin(int[] nums){
        return findMin(nums, 0, nums.length - 1);
    }
    
    public int findMin(int[] nums, int low, int high) {
        while(low < high){
            int mid = low + (high - low)/2;
            if(nums[mid] > nums[high]){
                low = mid + 1;
            }else if(nums[mid] < nums[high]){
                high = mid;
            }else{
                return Math.min(findMin(nums, low, mid), findMin(nums, mid + 1, high));
            }
        }
        return nums[high];
    }

Log in to reply
 

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