Problem
Two related bit-manipulation tasks. First, count the number of set (1) bits in an integer (the Hamming weight). Second, reverse the bits of a 32-bit unsigned integer so the least-significant bit becomes the most-significant and vice versa.
Input / Output
n.n.Constraints
n is a 32-bit unsigned integer.Example
countBits(0b1011) -> 3reverse(0b00000000000000000000000000000001) -> 0b10000000000000000000000000000000