C++超简洁解法
旋转数组的最小数字
http://www.nowcoder.com/questionTerminal/9f3231a991af4f55b95579b44b7a01ba
看到前面的题解似乎都很复杂,与我的思路都差不多,但是我的代码很简洁,上C++代码:
class Solution { public: int minNumberInRotateArray(vector<int> rotateArray) { if (rotateArray.size() <= 0) return 0; int l = 0, r = rotateArray.size() - 1; int mid; while (r - l > 1) { mid = (l + r) / 2; if (rotateArray[l] <= rotateArray[mid] && rotateArray[mid] >= rotateArray[r]) { l = mid; } else { r = mid; } } return rotateArray[r]; } };