Build the PrimitiveEasy
Number of 1 Bits
Write `hamming_weight(n)` counting the set bits in a non-negative integer.
hamming_weight(11) -> 3 (1011)
Shifting 32 times works. `n & (n - 1)` clears the lowest set bit, so the loop runs once per set bit instead — which matters when the value is mostly zeros. Know why it works: subtracting 1 flips the lowest set bit and everything below it.
What to expect: A timer starts when you begin. Edit the starter code, run it against the test suite as many times as you like, then finish when you're done. The reference solution and interviewer follow-up questions unlock only after you finish.