标签:while boolean ret version bad 错误 == 版本 extend
二分寻找边界
public class Solution extends VersionControl {
public int firstBadVersion(int n) {
int i = 1;
int j = n;
while (i<=j) {
int mid = i + ((j-i)>>1);
boolean ret = isBadVersion(mid);
if (ret == true) {
j = mid - 1;
} else {
i = mid + 1;
}
}
return i;
}
}
标签:while boolean ret version bad 错误 == 版本 extend
原文地址:https://www.cnblogs.com/acbingo/p/14883857.html