FunctionRacerProblemsRace

Reverse Bits

EasyBitsPython, JavaScript, TypeScript, Java, C++

Treat n as a 32 bit unsigned number. Reverse the order of its 32 bits and return the resulting number. For example, a number with only the lowest bit set becomes a number with only the highest bit set.

Example 1

n 1
returns 2147483648

1 becomes 2**31 = 2147483648.

Example 2

n 6
returns 1610612736

...0110 becomes 0110... which is 1610612736.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Bits problems