Find Minimum in Rotated Sorted Array II

Follow up for "Search in Rotated Sorted Array":
What if duplicates are allowed?

Would this affect the run-time complexity? How and why?

Write a function to determine if a given target is in the array.

my solution is accepted. but there are something i haven't figure out待我想明白,再解释

class Solution {
public:
    int findMin(vector<int> &num) {
        int low=0;
        int hi=num.size()-1;
        int mid=0;
        while(low<hi){
            mid=(low+hi)/2;
            if(num[mid]>=num[hi]) low=mid+1;
            else hi=mid;
        }
        int min=low;
        for(int i=low;i>=0;i--){
            if(i==0) {min=i;break;}
            if(num[i-1]>num[i]) {
                min=i;
                break;
            }
        }
        return num[min];
    }
};
原文地址:https://www.cnblogs.com/renrenbinbin/p/4332419.html