Took me 10s.

```
class Solution(object):
def guessNumber(self, n):
"""
:type n: int
:rtype: int
"""
l, r = 1, n
while l + 1 < r:
m = l + (r - l) / 2
res = guess(m)
if res < 0:
r = m
elif res > 0:
l = m
else:
return m
if guess(l) == 0:
return l
if guess(r) == 0:
return r
return None
```