LeetCode 278 First Bad Version
LeetCode 278 First Bad Version
// Forward declaration of isBadVersion API. bool isBadVersion(int version); int firstBadVersion(int n) { int start=1, end=n; while(start < end) { int mid=start+(end-start)/2; if(isBadVersion(mid)) end=mid; else start=mid+1; } return start; }