Number of 1 Bits
Return the number of one bits in the unsigned 32-bit representation of n.
Example 1
n = 21474836492Explanation
2147483649 sets the highest and lowest bits, giving two.
Example 2
n = 429496729532Explanation
All 32 bits are set in the largest unsigned 32-bit value.
Example 3
n = 00Explanation
Zero has no set bits.
Constraints
- 0 <= n <= 4294967295
Function contract
hammingWeightArguments: jsonSolutionRuns on your device
Loading draft…
Run: 3 examples; Submit: 33 cases, on your device.
2147483649