LeetCode 190. Reverse Bits Posted on 2021-03-29 Edited on 2024-11-24 In LeetCode 1234567891011class Solution {public: uint32_t reverseBits(uint32_t n) { int ans = 0; for (int i = 0; i < 32 && n > 0; ++i) { ans |= (n & 1) << (31 - i); n >>= 1; } return ans; }};