[LeetCode] Bitwise Manipulation
Most Significant Bit
Least Significant Bit
How to clear LSB
n & (n - 1)
Gray Code
Gray Code is a way to encode binary numbers so that between each number,
there is only 1 bit difference.
For example, we can encode 0~3 by 00 -> 01 -> 11 -> 10.
This is useful for switches and validating messages.
There are multiple ways to create gray code, but the easiest way is using mirror method.
We start from the most simple gray code: only 1 bit.
##
0xaa = 10101010
Bitwise Related LeetCode Problems
Single Number
Single Number II
Power of Two
Power of Three
Power of Four