Reverse Bits
Try solving the Reverse Bits problem.
We'll cover the following
Statement
Given an unsigned 32-bit integer n
, we need to calculate a 32-bit unsigned integer with reversed bits. When we say “reverse” we don’t mean flipping the s to s and vice versa, but simply reversing the order in which they appear, i.e., from left-to-right to right-to-left.
Note: In certain programming languages, such as Java, we do not have an unsigned integer type. Therefore, both input and output values are provided as signed integers. This should not impact our implementation because the internal binary representation of integers remains the same, whether they are signed or unsigned. In Java, the compiler utilizes the s complement notation for representing signed integers.
Constraints:
- The input must be a binary string of length
Examples
Create a free account to view this lesson.
Continue your learning journey with a 14-day free trial.
By signing up, you agree to Educative's Terms of Service and Privacy Policy