# 【剑指offer】面试题8：旋转数组的最小数字

int FindMin(int* a, int size) {
int high = size - 1;
int low = 0;
int mid = (high + low) / 2;
while(low < high - 1) {
if (a[mid] > a[low]) {
low = mid;
} else {
high = mid;
}
mid = (low + high) / 2;
}

return a[high];
}

int FindMin(int* a, int size) {
int high = size - 1;
int low = 0;
int mid = (high + low) / 2;
while(low < high - 1) {
if (a[mid] > a[low]) {
low = mid;
} else {
high = mid;
}
mid = (low + high) / 2;
}
if (high == size - 1 && a[high] > a[low])
return a[0];

return a[high];
}

int FindMin(int* a, int size) {
if (a == NULL || size <= 0) {
cout << "Wrong input" << endl;
return -1;
}
int high = size - 1;
int low = 0;
int mid = (high + low) / 2;
while(low < high - 1) {
if (a[low] == a[high] && a[mid] == a[low]) { //先判断特殊情况
int minIndex = low;
for (int i = low; i < high; i ++) {
if (a[i] < a[minIndex]) minIndex = i;
}
return a[minIndex];
}

if (a[mid] > a[low]) {
low = mid;
} else {
high = mid;
}
mid = (low + high) / 2;
}
if (high == size - 1 && a[high] > a[low])
return a[0];

return a[high];
}

#### 剑指Offer面试题8（java版）:旋转数组的最小数字

2015-07-28 17:26:03

#### 面试题8：旋转数组中的最小数字

2013-07-19 22:56:14

#### 剑指offer第六题【旋转数组的最小数字】c++实现

2015-10-14 11:30:19

#### 剑指offer----旋转数组的最小数字----java实现

2016-07-14 15:34:09

#### 旋转数组的最小数字（剑指offer面试题）

2016-02-23 10:39:58

#### 剑指offer-8- Python实现旋转数组的最小数

2017-09-06 21:35:31

#### Python：旋转数组的最小数字

2017-07-19 20:28:30

#### 剑指offer（C++）——旋转数组的最小数字

2017-04-23 21:23:08

#### 剑指offer- 旋转数组的最小元素

2016-10-28 16:23:24

#### 旋转数组的最小数字 python

2017-02-18 20:42:37