# 旋转数组中的最小数字（多种方法）

class Solution {
public:
int minNumberInRotateArray(vector<int> rotateArray) {
sort(rotateArray.begin(),rotateArray.end());

return rotateArray[0];

}
};

class Solution {
public:
int minNumberInRotateArray(vector<int> rotateArray) {
int min=rotateArray[0];
for(int i=1;i<rotateArray.size();i++)
{
if(rotateArray[i]<min)
{
min=rotateArray[i];
}
}
return min;
}
};

class Solution {
public:
int shunxuchazhao(vector<int> rotateArray, int start, int end) {
int ans = rotateArray[start];
for(int i = start + 1; i <= end ; i++){
if(rotateArray[i] < ans)
ans = rotateArray[i];
}
return ans;
}
int minNumberInRotateArray(vector<int> rotateArray) {
int end = rotateArray.size() - 1;
if(end < 0)
return 0;
int start = 0;
int mid = start;
while(rotateArray[start] >= rotateArray[end]){

if (start == end - 1) {
mid = end;
break;
}
mid = (start + end) / 2;
if (rotateArray[start] == rotateArray[end] && rotateArray[start] == rotateArray[mid]) {
return shunxuchazhao(rotateArray, start, end);
}
if (rotateArray[start] <= rotateArray[mid])
start = mid;
else if(rotateArray[mid] <= rotateArray[end])
end = mid;
}
return rotateArray[mid];
}

};