class Solution:
def firstBadVersion(self, n):
"""
:type n: int
:rtype: int
"""
ans=[]
def bina(pre,last):
if pre==last:
ans.append(pre)
return
mid=(last+pre)//2
if isBadVersion(mid)==False:
bina(mid+1,last)
if isBadVersion(mid)==True:
bina(pre,mid)
bina(1,n)
return ans[0]
12-10
46
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-09
109
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
05-03
132
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
09-03
1076
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)