博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
LeetCode : First Bad Version
阅读量:4558 次
发布时间:2019-06-08

本文共 828 字,大约阅读时间需要 2 分钟。

You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the previous version, all the versions after a bad version are also bad.

Suppose you have n versions [1, 2, …, n] and you want to find out the first bad one, which causes all the following ones to be bad.

You are given an API bool isBadVersion(version) which will return whether version is bad. Implement a function to find the first bad version. You should minimize the number of calls to the API.

// Forward declaration of isBadVersion API.bool isBadVersion(int version);class Solution{      public:    int firstBadVersion(int n) {          int low=1, high=n;          while(low

转载于:https://www.cnblogs.com/chankeh/p/6850043.html

你可能感兴趣的文章
有名管道的非阻塞设置
查看>>
Git使用教程-idea系列中git使用教程
查看>>
diff.js 列表对比算法 源码分析
查看>>
模块运用,文件搜索
查看>>
基于托管C++的增删改查及异步回调小程序
查看>>
hdu 1811 Rank of Tetris
查看>>
56. Merge Intervals 57. Insert Interval *HARD*
查看>>
java 调整jvm堆大小上限
查看>>
浏览器全屏之requestFullScreen全屏与F11全屏
查看>>
软件包管理:rpm命令管理-安装升级与卸载
查看>>
旋转图像
查看>>
字符串中的数字(字符串、循环)
查看>>
15.select into
查看>>
缓存-->Java中缓存的原理
查看>>
运行web项目端口占用问题
查看>>
Java Spring-IOC和DI
查看>>
【NOIP1999】【Luogu1015】回文数(高精度,模拟)
查看>>
Linux上安装Python3.5
查看>>
crt安装
查看>>
git切换分支报错:error: pathspec 'origin/XXX' did not match any file(s) known to git
查看>>