LeetCode---Bit
sumhhhh1234
这个作者很懒,什么都没留下…
展开
-
Reverse Bit
这题很简单但是老是没过 因为 运算符优先级搞错 要有括号 class Solution { public: uint32_t reverseBits(uint32_t n) { if (n == 0) return 0; uint32_t bit; uint32_t result = 0; uin原创 2016-03-16 12:04:20 · 338 阅读 · 0 评论 -
power of n
Power of 2 return (n&(n-1)) ==0; n & (n-1)==0 is executed as n & ((n-1)==0) See https://en.wikipedia.org/wiki/OperatorsinCandC%2B%2B class Solution { public: bool isPowerOfTwo(int n) {原创 2016-02-27 11:10:46 · 412 阅读 · 0 评论 -
XOR usage
1. single number https://leetcode.com/problems/single-number/description/ 2. swap value原创 2017-10-03 12:42:27 · 235 阅读 · 0 评论