leetcode 方法整理2 - bit manipulation | Do not guess who I am
首先觀察一下bit representation0: 0
1: 1
2: 10
3: 11
4: 100
5: 101
6: 110
7: 111
8: 1000
9: 1001
10: 1010
11: 1011
12: 1100
13: 1101
14: 1110
15: 1111
16: 10000
有幾件事情必須觀察到
- 偶數和奇數可以由last bit 判斷
- 2^n 是leading bit 為1, 其餘為0
- 2^n 和前一位完全& =0
Read full article from leetcode 方法整理2 - bit manipulation | Do not guess who I am
No comments:
Post a Comment