Here is my JAVA solution, but get time limit exceed error

```
public class Solution extends GuessGame {
public int guessNumber(int n) {
int begin = 0;
int end = n + 1;
int start;
while(true){
start = (begin + end) / 2;
int result = guess(start);
if(result == 0) return start;
if(result < 0) end = start;
else begin = start;
}
}
}
```