美文网首页
153. Find Minimum in Rotated Sor

153. Find Minimum in Rotated Sor

作者: 刘小小gogo | 来源:发表于2018-08-22 23:35 被阅读0次
image.png
class Solution {
public:
    int findMin(vector<int>& nums) {
        int start = 0;
        int end = nums.size() - 1;
        while(start + 1  < end){
            int mid = start + (end - start) / 2;
            if(nums[mid] < nums[end]) end = mid;
            else start = mid + 1;
        }
        return min(nums[start], nums[end]);
    }
};

相关文章

网友评论

      本文标题:153. Find Minimum in Rotated Sor

      本文链接:https://www.haomeiwen.com/subject/zivuiftx.html