执行用时 :20 ms, 在所有 Python 提交中击败了82.66%的用户
内存消耗 :11.7 MB, 在所有 Python 提交中击败了32.27%的用户
Code:
class Solution(object):
def guessNumber(self, n):
"""
:type n: int
:rtype: int
"""
left,right=1,n
while True:
mid=(left+right)//2
a=guess(mid)
if a==0:return mid
elif a==-1:right=mid-1
else:left=mid+1