Skip to content

Commit 7fe96f4

Browse files
committed
contains duplicate solution
1 parent f9dc342 commit 7fe96f4

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

contains-duplicate/suhacs.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
function containsDuplicate(nums) {
2+
const setLength = [...new Set(nums)].length;
3+
const numLength = nums.length;
4+
5+
if (numLength === setLength) return false;
6+
else return true;
7+
}
8+
9+
console.log(containsDuplicate([1, 1, 1, 3, 3, 4, 3, 2, 4, 2]));

0 commit comments

Comments
 (0)