[leetcode]Find Minimum in Rotated Sorted Array II

public class Solution { 

public int findMin(int[] nums) {

 int len=nums.length;

 int low=0,high=len-1; 

while(low<high){

 if(nums[low]<nums[high]){

 return nums[low];

 }else if(nums[low]==nums[high]){

 while(nums[low]>nums[low+1]||low==high-1){ 

return nums[low+1]; 

low++; 

}

}else{ 

int mid=(low+high)/2;

 if(mid>0&&nums[mid]nums[high]) 

return nums[high]; 

else 

return nums[low]; }

 if(nums[low]<=nums[mid]) 

low=mid; 

else high=mid; 

}

 return nums[low];

 }

}

你可能感兴趣的:(LeetCode)