leetcodeSolution to some Leetcode problems written in C++ |
git clone git://git.dimitrijedobrota.com/leetcode.git |
Log | Files | Refs | README | LICENSE |
0154.cpp (434B)
0 class Solution {
1 public:
2 int findMin(const vector<int> &nums) const {
3 int low = 0, high = nums.size() - 1;
5 while (low < high) {
6 const int mid = low + (high - low) / 2;
7 if (nums[mid] > nums[high])
8 low = mid + 1;
9 else if (nums[mid] < nums[high])
10 high = mid;
11 else
12 high--;
13 }
15 return nums[low];
16 }
17 };