Given a non-negative integer n, return the number of 1 bits in its binary representation (also known as the Hamming weight).
n
1
n = 11
3
Why
1011 has three set bits.
n = 128
0 <= n <= 2^31 - 1
Topics
Implement hammingWeight in the editor and return the answer — printing it is never graded.
hammingWeight
Problem 45 of 1146 in the arena