Skip to content

Commit 6de4775

Browse files
committed
contains-duplicate solution
1 parent a6a8263 commit 6de4775

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

contains-duplicate/Yu-Won.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* 문제: https://leetcode.com/problems/contains-duplicate/
3+
*
4+
* 요구사항:
5+
* nums: number[]를 Input 으로 받았을 때
6+
* 중복된 값이 있을 경우 true 없다면 false 를 반환
7+
*
8+
* 해시맵 이용
9+
* */
10+
11+
const containsDuplicate = (nums) => {
12+
const set = new Set();
13+
14+
for(const num of nums) {
15+
if(set.has(num)) {
16+
return true;
17+
}
18+
set.add(num);
19+
}
20+
return false;
21+
22+
}

0 commit comments

Comments
 (0)