FastPrepReverse an Unsigned 32-bit Value
Problems/Reverse an Unsigned 32-bit Value

Reverse an Unsigned 32-bit Value

AMD logoAMD● EasyNEW GRADFULLTIMEONSITE INTERVIEW
QuestionFunctionExamplesConstraints

Problem statement

Source note: The source explicitly reports reversing 32-bit unsigned bits in the Apr6 technical interview. Numeric bounds and the portable long interface are authored completion; approximate source match 95%.

Reverse exactly 32 binary digits of the nonnegative integer value, including leading zero bits. Return the reversed bit pattern as a nonnegative integer. The wire type is 64-bit so values above the signed 32-bit maximum remain positive.

Function

reverseBits32(value: long) → long

Examples

Example 1

value = 1return = 2147483648

One has 31 leading zeros followed by a 1; reversal moves that 1 to bit 31.

Example 2

value = 43261596return = 964176192

The fixed-width reversal of 00000010100101000001111010011100 is 00111001011110000010100101000000.

Constraints

  • 0 <= value <= 4294967295.

More AMD problems

  • Insert After a Linked-List NodeONSITE INTERVIEW · Seen Oct 2026
  • LRU CacheONSITE INTERVIEW · Seen Oct 2026
  • Lowest Common Ancestor of a Binary TreePHONE SCREEN · Seen Oct 2026
All AMD interview questionsSee AMD hiring insights
Saved
public long reverseBits32(long value) {
    // Write your code here.
}
Checking account…