Skip to content

Latest commit

 

History

History
32 lines (23 loc) · 548 Bytes

File metadata and controls

32 lines (23 loc) · 548 Bytes

278. First Bad Version

难度: Easy

刷题内容

原题连接

思路:

根据 search for a range 改的

class Solution(object):
    def firstBadVersion(self, n):
        """
        :type n: int
        :rtype: int
        """
        low, high = 0, n
        while low < high:
            mid = (low+high)//2
            if isBadVersion(mid):
                high = mid
            else:
                low = mid + 1
        return low