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.
2 parents c8870f6 + b589fd2 commit d19b3deCopy full SHA for d19b3de
contains-duplicate/0-chan.ts
@@ -0,0 +1,8 @@
1
+/**
2
+ * time complexity : O(n)
3
+ * space complexity : O(n)
4
+ */
5
+function containsDuplicate(nums: number[]): boolean {
6
+ const hasDuplicate = new Set(nums).size !== nums.length;
7
+ return hasDuplicate;
8
+};
number-of-1-bits/0-chan.ts
@@ -0,0 +1,10 @@
+ * time complexity : O(logn)
+ * space complexity : O(logn)
+function hammingWeight(n: number): number {
+ const MAX_NUM = 2147483648 - 1;
+
+ const bitwiseOperated = (n & MAX_NUM).toString(2);
9
+ return bitwiseOperated.replaceAll('0', '').length;
10
0 commit comments