【leetcode❤python】 278. First Bad Version

#-*- coding: UTF-8 -*-
# The isBadVersion API is already defined for you.
# @param version, an integer
# @return a bool
# def isBadVersion(version):

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

posted @ 2016-11-13 19:29  火金队长  阅读(205)  评论(0编辑  收藏  举报