class Solution {
public:
int minNumberInRotateArray(vector<int> rotateArray) {
if (rotateArray.size()==0) {
return 0;
}
int low=0, high=rotateArray.size()-1;
int mid=0;
while (rotateArray[low]>=rotateArray[high]) {
if (high==low+1){
return rotateArray[high];
}
mid = (low+high) / 2;
if (rotateArray[mid]>=rotateArray[low]) {
low = mid;
}else{
high = mid;
}
}
return rotateArray[high];
}
};
旋转数组
最新推荐文章于 2023-09-03 18:08:01 发布