This is a problem excersice from codesignal platform.
Presented with the integer
n, find the 0-based position of the second rightmost zero bit in its binary representation (it is guaranteed that such a bit exists), counting from right to left.
Return the value of
n = 37, the output should be
secondRightmostZeroBit(n) = 8.
3710 = 1001012. The second rightmost zero bit is at position
3(0-based) from the right in the binary representation of
Thus, the answer is
23 = 8.