Share my coding for REVERSE BITS


  • 0
    I
     int32_t reverseBits(uint32_t n) {
            int str[32],i;
            int num=0;
            for(i=0;n!=0;i++)
            {
                str[i]=n%2;
                n=n/2;  
            }
            for(int j=0;j<i;j++)
            {
                num+=(str[j]<<(31-j));
            }
            return num;
        }

Log in to reply
 

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