美文网首页
278. First Bad Version

278. First Bad Version

作者: 夜皇雪 | 来源:发表于2016-11-24 11:39 被阅读0次
    public class Solution extends VersionControl {
        public int firstBadVersion(int n) {
            int start = 1, end = n;
            while (start < end) {
                int mid = start + (end-start) / 2;
                if (!isBadVersion(mid)) start = mid + 1;
                else end = mid;            
            }        
            return start;
        }
    }
    

    相关文章

      网友评论

          本文标题:278. First Bad Version

          本文链接:https://www.haomeiwen.com/subject/azebpttx.html