C++ 1 liner 4ms


  • 0
    A
    class Solution {
    public:
        uint32_t reverseBits(uint32_t n) {
            return bitset<32>(string(
                              bitset<32>(n).to_string().rbegin(), 
                              bitset<32>(n).to_string().rend())).
                              to_ulong();
        }
    };
    

Log in to reply
 

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