Skip to content

Commit 9e763c1

Browse files
committed
add solution : 217. Contains Duplicate
1 parent 774b615 commit 9e763c1

File tree

2 files changed

+14
-22
lines changed

2 files changed

+14
-22
lines changed

contains-duplicate/mmyeon.js

Lines changed: 0 additions & 22 deletions
This file was deleted.

contains-duplicate/mmyeon.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)