https://leetcode.com/problems/first-bad-version/description/
int firstBadVersion(int n) {
int lo = 1, hi = n;
while(lo<hi){
int mid = lo +(hi - lo)/2;
if(isBadVersion(mid)) hi = mid;
else lo = mid + 1;
}
return lo;
}
No comments:
Post a Comment