class Solution {
public int minArray(int[] numbers) {
if( numbers == null || numbers.length == 0) return -1;
int lo = 0, hi = numbers.length - 1;
int mid = lo;
while( numbers[lo] >= numbers[hi] ) {
mid = (hi - lo)/2 + lo;
if( lo + 1 == hi){
mid = hi;
break ;
}
if(numbers[lo] == numbers[hi] && numbers[lo] == numbers[mid]){
return min(numbers, lo, hi);
}
if(numbers[mid] >= numbers[lo]){
lo = mid;
}else if(numbers[mid] <= numbers[hi]){
hi = mid;
}
}
return numbers[mid];
}
private int min(int[] a,int lo, int hi){
int min = a[lo];
for(int i = lo + 1; i <= hi; i++){
if(a[i] < a[lo]){
min = a[i];
}
}
return min;
}
}