/**
* 剑指 Offer 11. 旋转数组的最小数字
* https://leetcode.cn/problems/xuan-zhuan-shu-zu-de-zui-xiao-shu-zi-lcof/
*
* 输入:numbers = [3,4,5,1,2]
* 输出:1
* */
public class Solution {
public int minArray(int[] numbers) {
int start = 0;
int end = numbers.length - 1;
while (start < end) {
int mid = start + (end - start) / 2;
if (numbers[mid] > numbers[end]) { // 说明 mid 在左半边数组
start = mid + 1;
} else if (numbers[mid] < numbers[end]){ // 说明 mid 在右半边数组
end = mid;
} else {
end--; // 无法判断 mid 在左/右半边,右边缩小一个范围
}
}
return numbers[start];
}
}