BBox·DSASDE-2Technical Phone Screen
Number of 1 Bits
Problem
Count the number of set bits in an unsigned integer.
Example
11 (0b1011) -> 3
Constraints
- 32-bit unsigned
Approach
Brian Kernighan's n &= n-1. Reported Box question.
added 6 days ago
Count the number of set bits in an unsigned integer.
11 (0b1011) -> 3
Brian Kernighan's n &= n-1. Reported Box question.