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 f291ae8 commit 0e743b7Copy full SHA for 0e743b7
โcontains-duplicate/jiji-hoon96.tsโ
@@ -0,0 +1,11 @@
1
+/**
2
+ * ๋ฐฐ์ด์ ์ค๋ณต๋ ์์๊ฐ ์๋์ง ํ์ธํ๋ ํจ์
3
+ * @param nums - ํ์ธํ ์ ์ ๋ฐฐ์ด
4
+ * @returns ์ค๋ณต๋ ์์๊ฐ ์์ผ๋ฉด true, ๋ชจ๋ ์์๊ฐ ๊ณ ์ ํ๋ฉด false
5
+ *
6
+ * ๊ธฐ์กด์ for๋ฌธ์ ์ฌ์ฉํด filter,indexOf ๋ฐฉ์์ ์ฌ์ฉํ์ง๋ง, ์๊ฐ๋ณต์ก๋๊ฐ O(n^2)์ด๋ผ์ ์๊ฐ์ด๊ณผ๊ฐ ๋ฐ์ํ๋ค.
7
+ * Set์ ์ฌ์ฉํ๋ฉด ์ค๋ณต๋ ์์๋ฅผ ์ ๊ฑฐํ๊ณ , size๋ฅผ ํตํด ์ค๋ณต๋ ์์๊ฐ ์๋์ง ํ์ธํ ์ ์๋ค.
8
+ */
9
+function containsDuplicate(nums: number[]): boolean {
10
+ return new Set(nums).size !== nums.length
11
+};
0 commit comments