Skip to main content
PreparationZone Logo
PreparationZone
Back to Coding

Coding · Medium · Pro

Reverse bits of a 32-bit integer

CodingBit ManipulationSenior
Model answerPreview

Approach

  • Shift result left, take LSB of n, shift n right.
  • Repeat 32 times.

Java Solution

Java
int reverseBits(int n) {
    int an…