Reverse Bits

EasyBit ManipulationBit Manipulation

Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.

Practice this as a mock interviewFree to start, no account needed

Problem

Reverse bits of a given 32 bits unsigned integer. Note: in some languages there is no concept of unsigned integer; the input and output will be given as signed integer type, but the internal binary representation is the same.

Examples

Input: n = 00000010100101000001111010011100
Output: 964176192 (00111001011110000010100101000000)
Input: n = 11111111111111111111111111111101
Output: 3221225471 (10111111111111111111111111111111)

Constraints

  • The input must be a binary string of length 32.

What the interviewer grades

A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.

More Bit Manipulation problems