Find Minimum in Rotated Sorted Array II LeetCode solution in C++

1
class Solution {
2
public:
3
int findMin(vector<int> &nums) {
4
int l = 0, h = nums.size() - 1;
5
while (l < h) {
6
int m = l + (h - l) / 2;
7
if (nums[m] < nums[h])
8
h = m;
9
else if (nums[m] > nums[h])
10
l = m + 1;
11
else
12
h--;
13
}
14
return nums[h];
15
}
16
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0