278. 第一个错误的版本
作者:互联网
1 # The isBadVersion API is already defined for you. 2 # @param version, an integer 3 # @return a bool 4 # def isBadVersion(version): 5 6 class Solution(object): 7 def firstBadVersion(self, n): 8 """ 9 :type n: int 10 :rtype: int 11 """ 12 i, j = 1, n 13 while i < j: 14 mid = i + int((j - i) / 2) 15 if isBadVersion(mid): 16 j = mid 17 else: 18 i = mid+1 19 return j 20 21 22 if __name__ == '__main__': 23 solution = Solution() 24 print(solution.firstBadVersion(5))
标签:__,firstBadVersion,错误,int,isBadVersion,mid,version,版本,278 来源: https://www.cnblogs.com/panweiwei/p/12748600.html