leetcodelower_bound

Posted shulin~

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了leetcodelower_bound相关的知识,希望对你有一定的参考价值。

int binary_search(const vector<int>& stones,int val){
    int sz=stones.size();
    int l=0,r=sz-1;
    while(l<=r){
        int mid=(l+r)>>1;
        if(stones[mid]>=val){
            r=mid-1;
        }else{
            l=mid+1;
        }
    }
    return l;
}

 

以上是关于leetcodelower_bound的主要内容,如果未能解决你的问题,请参考以下文章