Easy
Count how many set bits appear in an integer.
Return the number of 1 bits in the binary representation of a 32-bit integer.
Examples
Input: n = 11
Output: 3
Explanation: Binary 1011 contains three 1 bits.
Constraints
- Use bit operations
Coding Challenge
Count how many set bits appear in an integer.
Return the number of 1 bits in the binary representation of a 32-bit integer.
Input: n = 11
Output: 3
Explanation: Binary 1011 contains three 1 bits.
Preparing your coding workspace...