Easy C Solution


  • 0
    A
    uint32_t reverseBits(uint32_t n) {
    
    uint32_t res = 0;
    uint32_t inter = 0;
    int i;
    
    for (i = 0; i< sizeof(n)*8;i++)
    {
        inter = n&1;
        res = res | inter << (sizeof(n)*8-1-i);
        n = n>>1;
    }
    return res;
    }

Log in to reply
 

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