Number of 1 Bits
Easy
Math
Bit Manipulation
Return the number of 1 bits (Hamming weight) of an unsigned integer.
Constraints
Input is a 32-bit unsigned integer
Examples
Example 1:
Input: 11
Output: 3
Explanation: 11 = 1011 in binary
Example 2:
Input: 128
Output: 1
Tests:
Runtime:
Memory:
Test
Input:
Expected:
Got:
Click Run Code to test against sample cases, or Submit to test against all cases.
▲ Console