Skip to content

Commit 73b4d9d

Browse files
committed
1.contains-duplicate 해결
1 parent 53ce7c7 commit 73b4d9d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

contains-duplicate/namgiho96.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* @param {number[]} nums
3+
* @return {boolean}
4+
* @Description
5+
* 1. Set을 사용하여 중복된 값을 확인한다.
6+
* 2. Set의 크기가 nums의 길이와 다르면 중복된 값이 있다는 의미이므로 true를 반환한다.
7+
* 3. Set의 크기가 nums의 길이와 같으면 중복된 값이 없다는 의미이므로 false를 반환한다.
8+
*/
9+
10+
function containsDuplicate(nums: number[]): boolean {
11+
return new Set(nums).size !== nums.length;
12+
}

0 commit comments

Comments
 (0)