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 d9fcd03 commit e2b6507Copy full SHA for e2b6507
missing-number/yoonthecoder.js
@@ -0,0 +1,14 @@
1
+var missingNumber = function (nums) {
2
+ // store all the elemenst from nums in a Set
3
+ const set = new Set(nums);
4
+
5
+ // check the missing number by iterating through the index
6
+ for (i = 0; i <= nums.length; i++) {
7
+ if (!set.has(i)) {
8
+ return i;
9
+ }
10
11
+};
12
13
+// Time complexity: O(n);
14
+// Space complexity: O(n);
0 commit comments