Dodomeki
Sign in

98. Mirror an octet

Medium

Given an unsigned integer that fits in 8 bits, return the value obtained by reversing the order of its eight bits. The result must also be an integer between 0 and 255.

Example 1
Input: numero = 22
Output: 104
Explanation: 22 is 00010110 in 8 bits; reversing the order gives 01101000, which is 104.
Example 2
Input: numero = 1
Output: 128
Constraints
  • 0 <= numero <= 255
Bits
Caso 1
numero =
22
Expected =
104
Caso 2
numero =
1
Expected =
128

Run checks these 2 cases. Submit runs all 6, including hidden ones.