Simple, unoptimized C++ Solution


  • 0
    B
    uint32_t reverseBits(uint32_t n) {
        uint32_t output = 0x00000000;
        
        for(unsigned int i = 0; i < 32; i++) {
            output |= ((n >> i) & 0x00000001) << (31 - i);
        }
        
        return output;
    }

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.