
bitwise
文章平均质量分 55
chuandalishuo
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
190. Reverse Bits
Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return 964176192 (represented in binary as 001110010原创 2016-10-18 02:28:22 · 273 阅读 · 0 评论 -
191. Number of 1 Bits
Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight). For example, the 32-bit integer ’11' has binary representation 000000原创 2016-10-20 02:37:21 · 172 阅读 · 0 评论 -
201. Bitwise AND of Numbers Range
Given a range [m, n] where 0 For example, given the range [5, 7], you should return 4. 思路:从左到右比较m和n的二进制数,相同的base加起来,直到出现不同的base,停止比较,因为后面一定是0,1交错的,而前面的一定是相同的(比较过来的),只要返回这些相同部分。 public class原创 2016-10-20 06:59:38 · 180 阅读 · 0 评论 -
371. Sum of Two Integers
Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -. Example: Given a = 1 and b = 2, return 3. 思路:a^b异或等于无进位的加法,(a&b) 解法一: public class Solution {原创 2016-11-01 00:15:57 · 164 阅读 · 0 评论