88. Number of 1 Bits

Return how many 1 bits the binary representation of the positive integer n has (its Hamming weight).

Example 1

Input: n = 11
Output: 3
Explanation: 11 is 1011 in binary.

Example 2

Input: n = 128
Output: 1
Hint 1

n & (n − 1) removes the lowest 1 bit.

Bit Manipulation