First Bad Version
简单的二分模板就可以解决了,注意上下界
class Solution(object):
def firstBadVersion(self, n):
"""
:type n: int
:rtype: int
"""
start, end = 1, n
while start + 1 < end:
mid = start + (end - start) / 2
if isBadVersion(mid):
end = mid
else:
start = mid
return start if isBadVersion(start) else end