class Solution {
public:
int findMin(vector<int> &num) {
int start = 0;
int end = num.size()1;
int mid;
while(start<end){
if(num[start]<num[end])
break;
mid = start+(endstart)/2;
if(num[mid]>num[end]){
start = mid+1;
}
else if(num[mid]==num[end]){
start++;
end;
}
else
end= mid;
}
return num[start];
}
};
My C++ solution 24ms is there any better solution ?



My 6ms c++ soln
class Solution { public: int findMin(vector<int>& nums) { int low=0; int high=nums.size()1; while(low<high){ int mid=low+(highlow)/2; if (nums[mid]>nums[high]) low=mid+1; else if(nums[mid]<nums[high]) high=mid; else { //this is how you break th eequality condition. just increase or decrease the low or high to break the tie; if (nums[mid]<nums[low]) low++; else high; } } return nums[low]; } };