题解 | #旋转数组的最小数字#
旋转数组的最小数字
http://www.nowcoder.com/practice/9f3231a991af4f55b95579b44b7a01ba
import java.util.ArrayList;
public class Solution {
public int minNumberInRotateArray(int [] array) {
int left = 0;
int right = array.length;
int mid = (left+right)/2;
int min = array[0];
while(left<right-1){
if(array[mid]<min){
min = array[mid];
right = mid;
}
if(array[mid]>min){
left = mid;
}
if(array[mid]==min){
if(array[right-1]==min){
right--;
}else if(array[left]==min){
left++;
}
}
mid = (left+right)/2;
}
return min;
}
}