Number of 1 Bits
Return how many 1 digits appear when the non-negative integer n is written in binary.
Example 1
n 11
returns 3
11 is 1011 in binary, three ones.
Example 2
n 128
returns 1
10000000, one 1.
Constraints
0 <= n <= 2**31 - 1
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.