Mr. Algorithm have an integer number, which he want to reverse by following steps:
- Convert the number into binary string.
- Reverse binary string.
- Convert the reversed binary string back to integer.
Example:
For
x = 234
, the output should beReverseBit(x) = 87
.23410 = 111010102 => 010101112 = 8710
.Input/Output
- [input] integer x
A non-negative integer. - [output] integer
x
reversed as described above.
If you want, you can check my solution for only 1 euro! (check PayPal button below):
No comments:
Write comments