python binary


  • 0
    Y
    class Solution(object):
        def guessNumber(self, n):
            """
            :type n: int
            :rtype: int
            """
            high=n
            low=1
            while low<=high: 
                mid=(high+low)//2
                if guess(mid)==0:
                    return mid
                elif guess(mid)==1:
                    low=mid+1
                else:
                    high=mid                
            return -1
    

Log in to reply
 

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