旋转数组最小值
旋转数组的最小数字
http://www.nowcoder.com/questionTerminal/9f3231a991af4f55b95579b44b7a01ba
感觉这个题有点问题,最后一个if条件不加也能过通过测试,但是没有最后一个if是万万不行的.
import java.util.ArrayList;
public class Solution {
public int minNumberInRotateArray(int [] array) {
if(null == array || array.length==0){
return 0;
}
int left= 0;
int right = array.length-1;
while(left < right){
int middle = (left+right)/2;
if(array[middle] > array[middle+1]){
return array[middle+1];
}
if(array[middle]< array[left]){
right = middle;
}
if(array[middle]>array[left]){
left = middle;
}
if(array[middle] == array[left]){
left++;
}
} return array[left]; }
}