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 ace8fba commit 2ae9f86Copy full SHA for 2ae9f86
number-of-1-bits/gitsunmin.ts
@@ -0,0 +1,8 @@
1
+/**
2
+ * https://leetcode.com/problems/number-of-1-bits/
3
+ * time complexity : O(log n)
4
+ * space complexity : O(log n)
5
+ */
6
+function hammingWeight(n: number): number {
7
+ return n.toString(2).replaceAll('0', '').length
8
+}
0 commit comments