leetcode-190-easy
Reverse Bits
思路一: 遍历 32 位 bit,记录 bit 结果
public int reverseBits(int n) {
int result = 0;
int x = 32;
while (x-- > 0) {
int bit = n & 1;
result <<= 1;
if (bit == 1) {
result++;
}
n >>>= 1;
}
return result;
}

浙公网安备 33010602011771号