Skip to content

Commit d1fbcfb

Browse files
committed
contains duplicate
1 parent f909bb4 commit d1fbcfb

File tree

1 file changed

+1
-18
lines changed

1 file changed

+1
-18
lines changed

contains-duplicate/suhacs.js

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,7 @@
1-
/**
2-
* @description
3-
* time complexity: O(n)
4-
* space complexity: O(n)
5-
* approach/strategy:
6-
* 1. brute force + hash table
7-
*/
8-
9-
/**
10-
* @param {number[]} nums
11-
* @return {boolean}
12-
*/
13-
141
function containsDuplicate(nums) {
152
const setLength = [...new Set(nums)].length;
163
const numLength = nums.length;
17-
18-
if (numLength === setLength) return false;
19-
else return true;
4+
return numLength === setLength ? false : true;
205
}
21-
226
console.log(containsDuplicate([1, 1, 1, 3, 3, 4, 3, 2, 4, 2]));
23-
247
//

0 commit comments

Comments
 (0)