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 9ff7423 commit 52e8667Copy full SHA for 52e8667
number-of-1-bits/mandel-17.py
@@ -0,0 +1,10 @@
1
+import collections
2
+
3
+class Solution:
4
+ def hammingWeight(self, n: int) -> int:
5
+ two_digit = []
6
+ while n >= 1:
7
+ two_digit.append(n % 2)
8
+ n = n // 2
9
+ cnt_dict = collections.Counter(two_digit)
10
+ return cnt_dict[1]
0 commit comments