4ms C easy to understand


  • 0
    C
    uint32_t reverseBits(uint32_t n) {
         uint32_t result = 0x0;
         int i = 0;
         
         for (i = 0; i < 32; i++)
         {
             if (n & (0x1 << (31-i)))
             {
                 result |= (0x1 << i);
             }
         }
         
         return result;
    }

Log in to reply
 

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