class Solution {
public:
int findMin(vector<int>& nums) {
int n = nums.size() - 1;
while (n && nums[n] == nums[0]) {
--n;
}
int l = 0, r = n;
while (l < r) {
const int mid = l + r >> 1;
if (nums[mid] <= nums[n]) {
r = mid;
} else {
l = mid + 1;
}
}
return nums[r];
}
};