Problems / Bit Manipulation / Number of 1 Bits
#145 Easy Time O(1) Space O(1) Animated

Number of 1 Bits

Return the number of set bits (Hamming weight) in n.

LeetCode ↗
Approach: Bit Manipulation (n & n-1)
Click play to start
Step 0 / 0
Press play to start the visualization.

Steps