class Solution {
public:
uint32_t reverseBits(uint32_t n) {
uint32_t temp = 1, bit = 1, ans = 0;
bit <<= 31;
while(bit) {
if(n & bit) ans += temp;
temp <<= 1;
bit >>= 1;
}
return ans;
}
};
[Leetcode bit operation C++] 190. Reverse Bits
Guess you like
Origin blog.csdn.net/m0_37454852/article/details/113935933
Ranking