一、题目
. - 力扣(LeetCode)
153. 寻找旋转排序数组中的最小值
二、代码
class Solution {
public:
int findMin(vector<int>& nums) {
int left = 0;
int right = nums.size()-1;
int mid = (left+right)/2;
while(left<right)
{
if(nums[mid]>nums[nums.size()-1])
{
left = mid+1;
mid = (left+right)/2;
}
else if(nums[mid]<nums[nums.size()-1])
{
right = mid;
mid = (left+right)/2;
}
}
return nums[left];
}
};