LC 190
LeetCode 190 · Easy

Reverse Bits

Reverse the bits of a 32-bit unsigned integer.


Try it

Step through the core mechanic. The simulator below runs the bit manipulation shape this problem is built on.

Walk the pattern

No dedicated step-through for this one yet. The shape is Bit manipulation — its pattern page has the interactive walkthrough, the reference implementation, and a five-problem progression that this problem sits inside.

The approach

Shift the result left and OR in the input's lowest bit, 32 times. Each step peels one bit off the input and pushes it to the mirrored position.

AspectValue
PatternBit manipulation
Recognise it byReverse the 32 bits of an integer.
Time complexityO(1)
Space complexityO(1)
DifficultyEasy

Who asks it

Companies known to ask this problem, from public LeetCode company-tag aggregations. A signal of where to expect it, not a guarantee.