leetcode
This commit is contained in:
9
leetcode/191.py
Normal file
9
leetcode/191.py
Normal file
@@ -0,0 +1,9 @@
|
||||
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
|
||||
Reference in New Issue
Block a user