#-*- coding: UTF-8 -*-# The guess API is already defined for you.# @param num, your guess# @return -1 if my number is lower, 1 if my number is higher, otherwise return 0# def guess(num):#binary searchclass Solution(object):    def guessNumber(self, n…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 日期 题目地址:https://leetcode.com/problems/guess-number-higher-or-lower/#/description 题目描述 We are playing the Guess Game. The game is as follows: I pick a number from 1 to n. You ha…
一天一道LeetCode 本系列文章已全部上传至我的github,地址:ZeeCoder's Github 欢迎大家关注我的新浪微博,我的新浪微博 欢迎转载,转载请注明出处 (一)题目 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…
#回文数#Method1:将整数转置和原数比较,一样就是回文数:负数不是回文数#这里反转整数时不需要考虑溢出,但不代表如果是C/C++等语言也不需要考虑class Solution(object):    def isPalindrome(self, x):        """        :type x: int        :rtype: bool        """        if x<0:return False    …
#-*- coding: UTF-8 -*- class Solution(object):    hexDic={0:'0',1:'1',2:'2',3:'3',4:'4',5:'5',6:'6',7:'7',8:'8',9:'9',\            10:'a',            11:'b',            12:'c',            13:'d',            14:'e',            15:'f'}            def t…
class Solution(object):    def isUgly(self, num):        if num<=0:return False        comlist=[2,3,5];modflag=0                while True:            if num==1:break            for value in comlist:                tuple=divmod(num,value)            …
[LeetCode]375. Guess Number Higher or Lower II 解题报告(Python) 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址: https://leetcode.com/problems/guess-number-higher-or-lower-ii/description/ 题目描述: We are playing the Guess Game. The game is as f…
Leetcode之二分法专题-374. 猜数字大小(374. Guess Number Higher or Lower) 我们正在玩一个猜数字游戏. 游戏规则如下:我从 1 到 n 选择一个数字. 你需要猜我选择了哪个数字.每次你猜错了,我会告诉你这个数字是大了还是小了.你调用一个预先定义好的接口 guess(int num),它会返回 3 个可能的结果(-1,1 或 0): -1 : 我的数字比较小 1 : 我的数字比较大 0 : 恭喜!你猜对了! 示例 : 输入: n = 10, pick…
374. Guess Number Higher or Lower 二分查找就好 // Forward declaration of guess API. // @param num, your guess // @return -1 if my number is lower, 1 if my number is higher, otherwise return 0 int guess(int num); class Solution { public: int guessNumber(int…
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) wh…