Skip to content

Latest commit

 

History

History
12 lines (11 loc) · 187 Bytes

191.md

File metadata and controls

12 lines (11 loc) · 187 Bytes
  • 28ms
  • 72%
class Solution:
    def hammingWeight(self, n: int) -> int:
        ans = 0
        while n:
            if n&1: ans +=1
            n >>= 1
        return ans