Very easy c++ solution(9ms)


  • 0
    A
    uint32_t reverseBits(uint32_t n) 
    {
            uint32_t result = 0;
    	uint32_t shift = 1;
    	for (int i = 0; i < 32; i++)
    	{
            	if ( (n & shift) != 0)
    		{
    	 	result |= 1 << (31 - i);
    		}
    		shift <<= 1;
    	}
    	return result;
        }
    

Log in to reply
 

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