Java accept solution


  • 0
    public int findMin(int[] nums) {
        int l =0;
        int r = nums.length-1;
        if(nums[l] < nums[r])
        	return nums[l];
        while(l < r){
        	while(l< r && nums[l] <= nums[l+1])
        		l++;
        	while(l< r && nums[r] >= nums[r-1])
        		r--;
        	if(nums[l] >= nums[r])
        		return nums[r];
        }
        return nums[r];
    }

Log in to reply
 

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