Skip to content

Commit 833cfcf

Browse files
committed
contains duplicate solution
1 parent 345e956 commit 833cfcf

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

contains-duplicate/yeeZinu.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* @param {number[]} nums
3+
* @return {boolean}
4+
5+
nums 배열내의 아무 정수나 2개 이상 중복되면 true를 반복하는 함수.
6+
7+
시간 복잡도: O(n)
8+
*/
9+
var containsDuplicate = function (nums) {
10+
return nums.length !== new Set(nums).size
11+
}
12+
13+
console.log(containsDuplicate([1, 2, 3, 1])); // true
14+
// console.log(containsDuplicate([1, 2, 3, 4])); // false
15+
// console.log(containsDuplicate([1, 1, 1, 3, 3, 4, 3, 2, 4, 2])); // true

0 commit comments

Comments
 (0)