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 e645851 commit 216fbcbCopy full SHA for 216fbcb
number-of-1-bits/changhyumm.py
@@ -0,0 +1,11 @@
1
+class Solution:
2
+ def hammingWeight(self, n: int) -> int:
3
+ count = 0
4
+ # 시간복잡도 O(log n) 반으로 나누기 때문
5
+ while n > 0:
6
+ if n % 2 == 1:
7
+ count += 1
8
+ n = n // 2
9
+ else:
10
+ n = n / 2
11
+ return count
0 commit comments