// The API isBadVersion is defined for you.
// bool isBadVersion(int version);
int firstBadVersion(int n) {
int fir = 1, end = n;
while(fir < end){
int mid = fir + (end - fir) / 2;
if(isBadVersion(mid)){
end = mid;
}else{
fir = mid + 1;
}
}
return fir;
}
278. 第一个错误的版本个人解法
最新推荐文章于 2024-09-10 15:28:21 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)