Leetcode刷题(第374题)——猜数字大小
一、题目 二、示例
输入:n = 10, pick = 6
输出:6
输入:n = 1, pick = 1
输出:1
输入:n = 2, pick = 1
输出:1
输入:n = 2, pick = 2
输出:2
三、思路 典型的二分查找 四、代码
/**
* Forward declaration of guess API.
* @param {number} 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
* var guess = function(num) {
共有 0 条评论