标签:param forward 数字 turn end ESS span begin color
1 /** 2 * Forward declaration of guess API. 3 * @param num your guess 4 * @return -1 if num is lower than the guess number 5 * 1 if num is higher than the guess number 6 * otherwise return 0 7 * int guess(int num); 8 */ 9 10 class Solution 11 { 12 public: 13 int guessNumber(int n) 14 { 15 long long begin = 1; 16 long long end = n; 17 while(begin <= end) 18 { 19 long long mid = (begin + end)/2; 20 if(guess(mid) == -1) end = mid - 1; 21 else if(guess(mid) == 1) begin = mid + 1; 22 else return mid; 23 } 24 return -1; 25 } 26 };
标签:param forward 数字 turn end ESS span begin color
原文地址:https://www.cnblogs.com/yuhong1103/p/12781749.html