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 f78c3c6 commit fb50647Copy full SHA for fb50647
1 file changed
contains-duplicate/jjipper.ts
@@ -0,0 +1,16 @@
1
+/**
2
+ * https://leetcode.com/problems/contains-duplicate
3
+ * time complexity : O(n)
4
+ * space complexity : O(n)
5
+ */
6
+
7
+export function containsDuplicate(nums: number[]): boolean {
8
+ const seen = new Set<number>();
9
+ for (const num of nums) {
10
+ if (seen.has(num)) {
11
+ return true;
12
+ }
13
+ seen.add(num);
14
15
+ return false;
16
+};
0 commit comments