My c code with 4ms


  • 0

    uint32_t reverseBits(uint32_t n) {
    if(n==0) return 0;
    int i;
    int a=0,m=0;
    for(i=0;i<32;i++)
    {
    a=n&1;
    if(a==0)
    {
    n>>=1;
    m<<=1;
    }
    else
    {
    n>>=1;
    m<<=1;
    m=m+1;
    }
    }
    return m;
    }


Log in to reply
 

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