LeetCode-Bit Manipulation
R_zz
这个作者很懒,什么都没留下…
展开
-
LeetCode-342. Power of Four
问题:https://leetcode.com/problems/power-of-four/?tab=Description 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原创 2017-02-28 09:21:44 · 197 阅读 · 0 评论 -
LeetCode-191. Number of 1 Bits
问题:https://leetcode.com/problems/number-of-1-bits/?tab=Description Write a function that takes an unsigned integer and returns the number of ’1’ bits it has (also known as the Hamming weight). 给定一个无符号原创 2017-02-28 09:39:33 · 208 阅读 · 0 评论 -
LeetCode-476. Number Complement
问题:https://leetcode.com/problems/number-complement/?tab=Description Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation. N原创 2017-02-28 10:08:56 · 198 阅读 · 0 评论 -
LeetCode-461. Hamming Distance
问题:https://leetcode.com/problems/hamming-distance/?tab=Description The Hamming distance between two integers is the number of positions at which the corresponding bits are different.Given two integers原创 2017-02-28 10:19:17 · 162 阅读 · 0 评论 -
LeetCode-405. Convert a Number to Hexadecimal
问题:https://leetcode.com/problems/convert-a-number-to-hexadecimal/?tab=Description 十进制转十六进制。 Given an integer, write an algorithm to convert it to hexadecimal. For negative integer, two’s complement m原创 2017-02-28 10:52:10 · 202 阅读 · 0 评论 -
LeetCode-190. Reverse Bits
问题:https://leetcode.com/problems/reverse-bits/?tab=Description Reverse bits of a given 32 bits unsigned integer.把二进制数翻转。 For example, given input 43261596 (represented in binary as 0000010100101000原创 2017-02-28 11:22:29 · 240 阅读 · 0 评论 -
LeetCode-371. Sum of Two Integers
问题:https://leetcode.com/problems/sum-of-two-integers/?tab=Description Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -. 计算两个整数的和,但你不能用任何的+ -操作符。 Example原创 2017-02-28 15:59:28 · 186 阅读 · 0 评论 -
LeetCode-338. Counting Bits
问题: https://leetcode.com/problems/counting-bits/?tab=Description Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1’s in their binary repr原创 2017-03-02 11:22:26 · 336 阅读 · 0 评论