For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return 964176192 (represented in binary as 00111001011110000010100101000000).
题目解析:将一个数字的2进制反转然后输出
解法解析:位运算的考察,将输入数字n&1取到其最右边位,,输出result向左移位通过异或接受新的字符,整个过程比较简单,上AC代码
public int reverseBits(int n) {
int result = 0;
for (int i = 0; i < 32; i++) {
result = (result << 1) | (n & 1);
n = n >> 1;
}
return result;
}