Simple Python Solution


  • 0
    2

    This is actually simple binary search

    class Solution(object):
        def firstBadVersion(self, n):
            """
            :type n: int
            :rtype: int
            """
            i = 1
            j = n
            while i <= j:
                m = i + (j - i) / 2
                if isBadVersion(m):
                    j = m - 1
                else:
                    i = m + 1
            
            return i

Log in to reply
 

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