题解 | #旋转数组的最小数字#
旋转数组的最小数字
https://www.nowcoder.com/practice/9f3231a991af4f55b95579b44b7a01ba
class Solution {
public:
int minNumberInRotateArray(vector<int> rotateArray) {
int left = 0;int i =0;
int right = rotateArray.size()-1;
for(;i <= right;i++){
if(rotateArray[i]>rotateArray[(i+1)%(right+1)])
break;
}
return rotateArray[(i+1)%(right+1)];
}
};
二分思想好难,暂时只能想到笨办法