原题链接:力扣
solution:
// The API isBadVersion is defined for you.
// bool isBadVersion(int version);
class Solution {
public:
int firstBadVersion(int n) {
int l=0,r=n;
while(l<r){
int mid=(long long)l+r>>1;
if(isBadVersion(mid)) r=mid;
else l=mid+1;
}
return r;
}
};