Not too much to say, just go with binary search:)

```
def guessNumber(self, n):
"""
:type n: int
:rtype: int
"""
s, e = 1, n
while s < e:
mid = (s + e) / 2
ret = guess(mid)
if ret == 0:
return mid
if ret == -1:
e = mid - 1
if ret == 1:
s = mid + 1
return s
```

very straightforward code.