ruijiege

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

https://leetcode-cn.com/problems/first-bad-version/

public int firstBadVersion(int n) {
        int left=0,right=n,mid;
        while (left<right){
            mid = ((right-left)>>1)+left;
            if (isBadVersion(mid)){
                right = mid;
            }else {
                left = mid + 1;
            }
        }
        return left;
    }

 

posted on 2021-07-22 17:47  哦哟这个怎么搞  阅读(20)  评论(0编辑  收藏  举报