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 774b615 commit 9e763c1Copy full SHA for 9e763c1
contains-duplicate/mmyeon.js
contains-duplicate/mmyeon.ts
@@ -0,0 +1,14 @@
1
+/**
2
+ *
3
+ * 접근 방법 :
4
+ * - set 자료구조에 nums 값 담아서 set의 크기와 배열의 길이를 비교하기
5
6
+ * 시간복잡도 : O(n)
7
+ * - nums 배열을 순회해서 set에 저장하니까 O(n)
8
9
+ * 공간복잡도 : O(n)
10
+ * - nums 배열의 길이만큼 set에 담으니까 O(n)
11
+ */
12
+function containsDuplicate(nums: number[]): boolean {
13
+ return nums.length !== new Set([...nums]).size;
14
+}
0 commit comments