Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions contains-duplicate/naringst.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* @param {number[]} nums
* @return {boolean}
*/

/**
* Runtime: 89ms, Memory: 63MB
*
* Time complexity: O(n)
* - To find the length of an array: O(n)
* - Array to Set: O(n)
* - To find the size of a set: O(n)
* Space complexity: O(n)
* - arrToSet: O(n)
*
* **/

var containsDuplicate = function (nums) {
const arrLength = nums.length;
const arrToSet = new Set(nums);
const setLength = arrToSet.size;

if (arrLength !== setLength) {
return true;
}
return false;
};