Given a non-negative integer n, return the number of set bits in its binary representation. Pattern focus: Clear Lowest Bit. Repeatedly remove the lowest set bit using n & (n - 1) until the number becomes zero.
n = non-negative integer
count of set bits in n
Example 1:
Input:
n = 11
Output:
3
Explanation:
11 in binary is 1011, which has three set bits.
Example 2:
Input:
n = 0
Output:
0
Explanation:
Zero has no set bits.