题解 | #二分#
旋转数组的最小数字
http://www.nowcoder.com/practice/9f3231a991af4f55b95579b44b7a01ba
二分
class Solution { public: int minNumberInRotateArray(vector<int> nums) { int n = nums.size(); if(n == 0) return 0; int left = 0, right = n - 1; int res = INT_MAX; while(left < right){ int mid = left + (right - left) / 2; if(nums[left] == nums[mid]){ res = min(res, nums[left]); left ++; continue; } if(nums[mid] > nums[left]){ res = min(res, nums[left]); left = mid + 1; }else{ right = mid; } } res = min(res, nums[left]); return res; } };