We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ee1ad8e commit 0adea9cCopy full SHA for 0adea9c
contains-duplicate/naringst.js
@@ -0,0 +1,27 @@
1
+/**
2
+ * @param {number[]} nums
3
+ * @return {boolean}
4
+ */
5
+
6
7
+ * Runtime: 89ms, Memory: 63MB
8
+ *
9
+ * Time complexity: O(n)
10
+ * - To find the length of an array: O(n)
11
+ * - Array to Set: O(n)
12
+ * - To find the size of a set: O(n)
13
+ * Space complexity: O(n)
14
+ * - arrToSet: O(n)
15
16
+ * **/
17
18
+var containsDuplicate = function (nums) {
19
+ const arrLength = nums.length;
20
+ const arrToSet = new Set(nums);
21
+ const setLength = arrToSet.size;
22
23
+ if (arrLength !== setLength) {
24
+ return true;
25
+ }
26
+ return false;
27
+};
0 commit comments