Coding Challenge

Number of 1 Bits

Easy
bit-manipulation

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

Preparing your coding workspace...