Swap bits
Quesiton
Reverse bits of a given 32 bits unsigned interger
Follow up:
if the function is called many times, how would you optimize it?
Thoughts
方法1
按位swap, 利用bit mask等,要注意只有bit不相等的时候需要改变,就是将bit flip一下( 利用XOR)。
方法2 lookup table
这个方法可以对很多多Bits的题目,使用lookup table改进效率