Files
PS/leetcode/191.py
Gyubin Han dede0dca01 leetcode
2025-02-19 14:09:55 +09:00

10 lines
200 B
Python

class Solution:
def hammingWeight(self, n: int) -> int:
count=0
b=bin(n)
for i in range(2,len(b)):
if b[i]=="1":
count+=1
return count