C code for 0ms, easy to understand


  • 1
    A

    uint32_t reverseBits(uint32_t n) {

    uint32_t revern;
    
    if (n == 0)
    {
        return revern=0;
    }
    else
    {
    for(int i =0; i<32; i++)
    {
       if (n&(1<<i))
       {
         revern=revern+(0x80000000>>i);
       }
    }
    
    return revern;
    }
    

    }


Log in to reply
 

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