3064. Guess the Number Using Bitwise Questions I
There is a number
n
that you have to find.There is also a pre-defined API
int commonSetBits(int num)
, which returns the number of bits where bothn
andnum
are1
in that position of their binary representation. In other words, it returns the number of set bits inn & num
, where&
is the bitwiseAND
operator.Return the number
n
.
1 | /** |