-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path06.cpp
More file actions
39 lines (36 loc) · 654 Bytes
/
06.cpp
File metadata and controls
39 lines (36 loc) · 654 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <iostream>
#include <vector>
using namespace std;
int minNumberInRotateArray(vector<int> rotateArray)
{
int len = rotateArray.size();
if (!len)
return 0;
int low = 0, high = len - 1;
while (low < high)
{
int mid = low + ((high - low) >> 1);
if (rotateArray[mid] > rotateArray[high])
low = mid + 1;
else if (rotateArray[mid] < rotateArray[high])
high = mid;
else
high--;
}
return rotateArray[low];
}
int main()
{
ios::sync_with_stdio(false);
vector<int> v;
int n;
cin >> n;
for (int i = 0; i < n; i++)
{
int temp;
cin >> temp;
v.push_back(temp);
}
cout << minNumberInRotateArray(v) << endl;
return 0;
}