10 lines
200 B
Python
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
|