标签:
class Solution { public: int minNumberInRotateArray(vector<int> rotateArray){ int len = rotateArray.size(); if( len < 1){ return 0; } int low = 0; int high = len - 1; while(low < high){ int mid = (low + high)/2; if(rotateArray[low] < rotateArray[high]){ return rotateArray[low]; } if(high - low == 1){ return rotateArray[high]; } if(rotateArray[mid] == rotateArray[low] && rotateArray[mid] == rotateArray[high]){ int min = rotateArray[low]; for(int i = low; i <= high; ++i){ if(min > rotateArray[i]){ min = rotateArray[i]; } } return min; } if(rotateArray[mid] >= rotateArray[low]){ low = mid; } else if(rotateArray[mid] <= rotateArray[high]){ high = mid; } } } };
标签:
原文地址:http://www.cnblogs.com/code-changeworld/p/4542251.html