Skip to content

Commit cdbd856

Browse files
committed
contains duplicate solution
1 parent f291ae8 commit cdbd856

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

contains-duplicate/froggy1014.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Set을 사용한 중복값 제거 후 길이 비교
2+
function containsDuplicate(nums) {
3+
const numSet = new Set(nums);
4+
return numSet.size !== nums.length;
5+
}
6+
7+
console.log(containsDuplicate([1, 2, 3, 1])); // true
8+
console.log(containsDuplicate([1, 2, 3, 4])); // false
9+
console.log(containsDuplicate([1, 1, 1, 3, 3, 4, 3, 2, 4, 2])); // true

0 commit comments

Comments
 (0)