My c++ binary search solution


  • 0
    D

    int findMin(vector<int> &num) {
    int start = 0, end = num.size()-1;
    while(start<end){
    while(start<end && num[start]==num[end])
    start++;
    if(num[start]<num[end])
    return num[start];
    int mid = start + ((end-start)>>1);
    if (num[mid]<=num[end])
    end = mid;
    else
    start = mid+1;
    }
    return num[start];
    }


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.