Python + Binary Search

  • 0
        def bisearch(self, upper, n):
            mid = upper / 2
            if not isBadVersion(mid) and isBadVersion(mid + 1):
                return mid + 1
            elif not isBadVersion(mid):
                return self.bisearch(mid + n, n)
                return self.bisearch(mid, mid)
        def firstBadVersion(self, n):
            return self.bisearch(n, n)

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.