Skip to content

Commit e603d16

Browse files
committed
add solution: contains-duplicate
1 parent b6649b8 commit e603d16

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

contains-duplicate/HerrineKim.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// 시간복잡도: O(n)
2+
3+
/**
4+
* @param {number[]} nums
5+
* @return {boolean}
6+
*/
7+
var containsDuplicate = function (nums) {
8+
const seen = new Set();
9+
for (let num of nums) {
10+
if (seen.has(num)) {
11+
return true; // 중복 발견
12+
}
13+
seen.add(num);
14+
}
15+
return false; // 모든 요소가 고유
16+
};

0 commit comments

Comments
 (0)