C++ Solution (3ms)


  • 1
    I
    uint32_t reverseBits(uint32_t n) {
            string tmp="";
            for(int i=31;i>=0;i--){
                tmp.push_back((n%2)+'0');
                n>>=1;
            }
            std::bitset<32> bVal(tmp);
            return bVal.to_ulong();
        }
    

Log in to reply
 

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