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 ed823ca commit 3b96320Copy full SHA for 3b96320
number-of-1-bits/hozzijeong.js
@@ -0,0 +1,10 @@
1
+/**
2
+ * @param {number} n
3
+ * @return {number}
4
+ */
5
+var hammingWeight = function(n) {
6
+ const binary = n.toString(2);
7
+
8
9
+ return binary.replaceAll('0','').length
10
+};
0 commit comments