Last active
October 28, 2019 17:04
-
-
Save thomasvaeth/a02beebedf5befa27b6b2429a6cef11e to your computer and use it in GitHub Desktop.
"The successful warrior is the average man, with laser-like focus." - Bruce Lee
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function missingInts(arr) { | |
if (arr.length < 2) return []; | |
const missingNums = []; | |
const set = new Set(arr); | |
for (let i = 1; i < arr[arr.length - 1]; i++) { | |
if (!set.has(i)) missingNums.push(i); | |
} | |
return missingNums; | |
} | |
missingInts([1, 3, 3, 3, 5, 6]); | |
missingInts([1, 2, 3, 4, 4, 7, 7]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment