class Solution
{
public:
    int findMin(vector<int> &nums)
    {
        int size = nums.size();
        if (size == 1)
            return nums[0];
        if (nums[0] < nums[size - 1])
            return nums[0];
        data = nums;
        return find(0, size - 1);
    }
    int find(int first, int second)
    { //闭区间
        if (first == second)
            return data[second];
        if (first + 1 == second)
            return data[second];
        int min = data[second];
        int mid = data[(first + second) / 2];
        if (mid == min)
        {
            int sgn1 = find((first + second) / 2, second);
            int sgn2 = find(first, (first + second) / 2);
            return (sgn1 < sgn2 ? sgn1 : sgn2);
        }
        if (mid > min)
            return find((first + second) / 2, second);
        if (mid < min)
            return find(first, (first + second) / 2);
    }

private:
    vector<int> data;
};
