![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
leetcode
探云观海
这个作者很懒,什么都没留下…
展开
-
461. Hamming Distance
思路:1、先求x^y的结果 2、计算结果中1的个数,即为汉明距离The Hamming distance between two integers is the number of positions at which the corresponding bits are different.Given two integers x and y, calcula原创 2017-02-28 11:18:25 · 150 阅读 · 0 评论 -
191. Number of 1 Bits [easy] (效率很低)
思路方法三种思路的速度都很慢,不知道为什么,找不到高效率的算法思路一按照定义,将输入的数表示成二进制的字符串,数一下有多少个1即可。代码class Solution(object): def hammingWeight(self, n): """ :type n: int :rtype: int转载 2017-03-01 16:42:46 · 224 阅读 · 0 评论 -
190. Reverse Bits [easy]
题目翻译翻转一个给定的32位无符号数的位。比如,给定输入整数43261596(二进制表示为00000010100101000001111010011100),返回964176192(二进制表示为00111001011110000010100101000000)。 进一步:如果该函数被多次调用,你该如何优化它?思路方法思路一先将输入转换成2进制字符串,再翻转并扩充转载 2017-03-01 18:13:01 · 226 阅读 · 0 评论 -
231. Power of Two [easy] 【python】
题目链接https://leetcode.com/problems/power-of-two/题目原文Given an integer, write a function to determine if it is a power of two.题目翻译给定一个整数,写一个函数判断它是否是2的若干次幂。思路方法思路二是最快的算法,计算一个转载 2017-03-02 11:11:56 · 252 阅读 · 0 评论 -
342. Power of Four【easy】【python】
Given an integer (signed 32 bits), write a function to check whether it is a power of 4.Example:Given num = 16, return true. Given num = 5, return false.Follow up: Could you solve it without翻译 2017-03-03 17:37:22 · 234 阅读 · 0 评论 -
136. Single Number [easy] [python]
Given an array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it without using ext翻译 2017-03-07 11:08:56 · 171 阅读 · 0 评论