思路
就是二分法的一个简单的变形
代码
//判断相等,以一边以基准,调整left和right
class Solution {
public int minArray(int[] numbers) {
int left= 0;
int right = numbers.length - 1;
while(left < right){
int mid = (left + right) >> 1;
if(numbers[mid] == numbers[right]){
right --;
}
else if(numbers[mid] > numbers[right]){
left = mid + 1;
}
else{
right = mid;
}
}
return numbers[left];
}
}