/* The guess API is defined in the parent class GuessGame. @param num, your guess @return -1 if my number is lower, 1 if my number is higher, otherwise return 0 int guess(int num); */publicclassSolutionextendsGuessGame {publicintguessNumber(int n) {int start =1, end = n, mid;while (start +1< end) { mid = start + (end - start) /2;int guessRst =guess(mid);if (guessRst ==0) {return mid; } elseif (guessRst ==-1) { end = mid; } else { start = mid; } }if (guess(start)==0) {return start; } else {return end; } }}