# 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:

class Solution:
    # # Binary Search (Accepted), O(log n) time, O(1) space
    # def guessNumber(self, n: int) -> int:
    #     low, high = 1, n
    #     while low <= high:
    #         mid = (low + high) // 2
    #         val = guess(mid)
    #         if val == 0:
    #             return mid
    #         elif val < 0:
    #             high = mid-1
    #         else:
    #             low = mid+1

    # Binary Search (Top Voted), O(log n) time, O(1) space
    def guessNumber(self, n: int) -> int:
        lo, hi = 1, n
        while lo < hi:
            mid = (lo + hi) // 2
            if guess(mid) == 1:
                lo = mid + 1
            else:
                hi = mid
        return lo

# 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:

class Solution:
    # # Binary Search (Accepted), O(log n) time, O(1) space
    # def guessNumber(self, n: int) -> int:
    #     low, high = 1, n
    #     while low <= high:
    #         mid = (low + high) // 2
    #         val = guess(mid)
    #         if val == 0:
    #             return mid
    #         elif val < 0:
    #             high = mid-1
    #         else:
    #             low = mid+1

    # Binary Search (Top Voted), O(log n) time, O(1) space
    def guessNumber(self, n: int) -> int:
        lo, hi = 1, n
        while lo < hi:
            mid = (lo + hi) // 2
            if guess(mid) == 1:
                lo = mid + 1
            else:
                hi = mid
        return lo

# 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: # # Binary Search (Accepted), O(log n) time, O(1) space # def guessNumber(self, n: int) -> int: #     low, high = 1, n #     while low <= high: #         mid = (low + high) // 2 #         val = guess(mid) #         if val == 0: #             return mid #         elif val < 0: #             high = mid-1 #         else: #             low = mid+1 # Binary Search (Top Voted), O(log n) time, O(1) space