# [LeetCode]#374. Guess Number Higher or Lower

Environment : Python 3.7

Key technique: Binary search

**Example :**

**Input: **n = 10, pick = 6

**Output: **6

**Solution:**

`class Solution:`

def guessNumber(self, n: int) -> int:

low=1

high=n

while low <= high:

mid = (low+high) // 2

if guess(mid) == 1:

low = mid + 1

else:

high = mid - 1

return low

**Reference:**

https://leetcode.com/problems/guess-number-higher-or-lower/solution/