# Easy
class Solution: def hammingWeight(self, n: int) -> int: count = 0 while n: if n & 1 == 1: count += 1 n = n >> 1 return count
Last updated 4 years ago
Was this helpful?