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 b9cb9d9 commit aec9943Copy full SHA for aec9943
โcontains-duplicate/soobing2.tsโ
@@ -0,0 +1,20 @@
1
+/**
2
+ * ๋ฌธ์ ์ ํ
3
+ * - Array
4
+ *
5
+ * ๋ฌธ์ ์ค๋ช
6
+ * - ์ค๋ณต๋ ์๊ฐ ์๋ ๊ฒฝ์ฐ true, ์์ผ๋ฉด false ๋ฐํ
7
8
+ * ์์ด๋์ด
9
+ * - ์ ์ฒด์ ์ผ๋ก ์ํํ๋ฉด์ ์ค๋ณต๋ ์๊ฐ ์๋์ง ํ์ธ
10
11
+ */
12
+function containsDuplicate(nums: number[]): boolean {
13
+ const set = new Set<number>();
14
+ for (let i = 0; i < nums.length; i++) {
15
+ if (set.has(nums[i])) return true;
16
+
17
+ set.add(nums[i]);
18
+ }
19
+ return false;
20
+}
0 commit comments