# 题目内容

You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the previous version, all the versions after a bad version are also bad.
Suppose you have n versions [1, 2, …, n] and you want to find out the first bad one, which causes all the following ones to be bad.
You are given an API bool isBadVersion(version) which will return whether version is bad. Implement a function to find the first bad version. You should minimize the number of calls to the API.
Credits:
Special thanks to @jianchao.li.fighter for adding this problem and creating all test cases.

# 代码示例

bool isBadVersion(int version);
class Solution {
public:
bool flag=false;
return 1;
int high=n;
int low=1;
int mid;
while(low<high)
{
mid=low+(high-low)/2;
low=mid+1;
else
high=mid;
}
return low;
}
};

#### leetcode 287: Find the Duplicate Number

2015-09-29 08:29:12

#### leetcode刷题 二分查找

2018-01-15 14:26:26

#### LeetCode基础-查找-排序数组二分查找

2017-11-02 08:59:51

#### LeetCode278 二分查找

2016-02-01 19:42:03

2015-09-09 09:44:39

#### LeetCode 之二分法查找 Binary search

2014-03-10 14:07:46

2015-10-14 14:03:41

#### Leetcode二分查找算法

2017-11-13 17:25:00

#### leetcode--二分查找和二分排序

2017-12-22 18:58:11

#### leetCode_Search for a Range（二分查找）

2016-06-16 09:55:51