2026-08-25 19:14:07 -06:00

12 lines
220 B
Python

def hammingWeight(self, n: int) -> int:
count = 0
while n>0:
if n&1==1:
count+=1
n>>=1
return count