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