leetcode
C++:
class Solution {
public:
int minArray(vector<int>& numbers) {
if ( numbers.empty() ) {
return 0;
}
int left = 0;
int right = numbers.size() - 1;
while ( left < right ) {
int middle = left + ( right - left ) / 2;
if ( numbers[middle] > numbers[right] ) {
left = middle + 1;
} else if ( numbers[middle] < numbers[right] ) {
right = middle;
} else {
--right;
}
}
return numbers[left];
}
};