3ms solution in C


  • 0
    B
    uint32_t reverseBits(uint32_t n) {
        int f = 0;
        uint32_t tmp = 0;
        while(f < 32){
            if (n & 1){
                //printf("%d\n" , f);
                tmp = tmp | (1 << (31 - f));
            }
            f++;
            n >>= 1;
        }
        return tmp;
        
    }
    

Log in to reply
 

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