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 位运算 C++】190. Reverse Bits
最新推荐文章于 2021-12-17 15:59:16 发布