dsa · easy

Number of One Bits

Given a non-negative integer n, return how many 1 bits it has in its binary representation (Hamming weight).

Arguments

Example

n = 11 is 10113 ones.

Constraints

0 <= n <= 2^31 - 1 Hidden tests include near-max size for this bound; a slower-than-intended solution TLEs.

Examples

Example 1

Input:
11

Expected:
3

Example 2

Input:
128

Expected:
1

Open in the Dojo editor