题解:
使用二分法
class Solution:
def guessNumber(self, n: int) -> int:
start = 1
end = n
while start <= end:
mid = (start + end) // 2
res = guess(mid)
if res == 0:
return mid
elif res == 1:
start = mid + 1
else:
end = mid - 1