154. Number of 1 Bits
EasyBit Manipulation
Write a function that takes the binary representation of a positive integer and returns the number of set bits it has (also known as the Hamming weight).
Examples
Input: 11
Output: 3
Explanation: 11 is 1011 in binary, which has three set bits.
Constraints
- 1 <= n <= 2^31 - 1
Loading...
Run checks all cases above. Submit evaluates all test cases.