# The guess API is already defined for you.# @param num, your guess# @return -1 if my number is lower, 1 if my number is higher, otherwise return 0# def guess(num: int) -> int:classSolution:defguessNumber(self,n:int) ->int: left =1 right = nwhile left <= right: mid = left + (right - left) //2ifguess(mid)==1: left = mid +1elifguess(mid)==-1: right = mid -1else:return mid