Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- uint32_t reverseBits(uint32_t n) {
- uint32_t result = 0;
- int stepen = 31;
- while(n > 0) {
- int bit = n % 2;
- n /= 2;
- if(bit == 1) {
- result += (1 << stepen);
- }
- stepen--;
- }
- return result;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement