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.
x = 234, the output should be
ReverseBit(x) = 87.
23410 = 111010102 => 010101112 = 8710.
- [input] integer x
A non-negative integer.
- [output] integer
xreversed as described above.
If you want, you can check my solution for only 1 euro! (check PayPal button below):