题目链接
https://leetcode.com/problems/guess-number-higher-or-lower/
题目原文
We are playing the Guess Game. The game is as follows:
I pick a number from 1 to n. You have to guess which number I picked.
Every time you guess wrong, I’ll tell you whether the number is higher or lower.
You call a pre-defined API guess(int num) which returns 3 possible results (-1, 1, or 0):
-1 : My number is lower
1 : My number is higher
0 : Congrats! You got it!Example:
n = 10, I pick 6.
Return 6.
题目翻译
猜数字游戏。游戏规则是这样的:我从1到n中挑选一个数,你来猜我挑的数是多少。每次你猜错了我都会告诉你正确数字是更大还是更小。
你写的函数可以调用一个预先实现的guess(int num)的接口,它能返回-1,0,1三个可能值:-1表示正确数字更小;1表示正确数字更大;0表示猜对了。
比如:当n=10,我选的数是6时&#x