10 lines
185 B
Python
10 lines
185 B
Python
class Solution:
|
|
def hammingWeight(self, n: int) -> int:
|
|
count = 0
|
|
|
|
while n:
|
|
n = n & (n - 1)
|
|
count += 1
|
|
|
|
return count
|