mirror of
https://github.com/halfrost/LeetCode-Go.git
synced 2025-07-25 12:14:26 +08:00
21 lines
418 B
Go
21 lines
418 B
Go
package leetcode
|
|
|
|
import "sort"
|
|
|
|
/**
|
|
* Forward declaration of guess API.
|
|
* @param num your guess
|
|
* @return -1 if num is lower than the guess number
|
|
* 1 if num is higher than the guess number
|
|
* otherwise return 0
|
|
* func guess(num int) int;
|
|
*/
|
|
|
|
func guessNumber(n int) int {
|
|
return sort.Search(n, func(x int) bool { return guess(x) <= 0 })
|
|
}
|
|
|
|
func guess(num int) int {
|
|
return 0
|
|
}
|