My C++ Code,easy to understand.


  • 0
    X
    uint32_t reverseBits(uint32_t n) {
            uint32_t sum = 0;
            for (int i=31; i>=0; i--) {
                sum +=   ((n>>i) &1) *pow(2, 31-i);  
            }   
            return sum  ;
        }

Log in to reply
 

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