class Solution {
public int minNumberInRotateArray(int [] array) {
if(array.length == 1 ){
return array[0];
}
return minNumber(array);
}
public static int minNumber(int [] array){
int L = 0;
int R = array.length - 1;
int mid = 0;
int K = 0;
while (L <= R){
mid = L + ((R - L) >> 1);
if (array[L] < array[R]){
return array[L];
}
if(array[mid] >array[L]){
L = mid + 1;
if (array[mid] < K ){
return array[mid];
}
K = array[mid];
}else if(array[mid] < array[L]){
R = mid - 1;
K = array[mid];
if (array[mid - 1] > K){
return K;
}
}
else{
L = L + 1;
}
}
return array[mid];
}
}