We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0fb50a8 commit c20a0afCopy full SHA for c20a0af
number-of-1-bits/yyyyyyyyyKim.py
@@ -0,0 +1,9 @@
1
+class Solution:
2
+ def hammingWeight(self, n: int) -> int:
3
+ answer = 0
4
+
5
+ while n > 0:
6
+ answer += n%2 #나머지(현재 비트가 1이면 ++)
7
+ n //= 2 #몫(다음 비트로 이동)
8
9
+ return answer
0 commit comments