168. Hamming Weight

Given an integer n. Return the number of set bits (1s) in its binary representation.
Example 1
Input: n = 11
Output: 3
Explanation: 11 = 1011, three set bits.
Example 2
Input: n = 128
Output: 1
Explanation: 128 = 10000000, one set bit.
bit manipulationeasy
JavaScript
Loading...
Line 1, Char 1