Skip to content

Instantly share code, notes, and snippets.

@cefaijustin
Last active September 7, 2018 01:24
Show Gist options
  • Save cefaijustin/5e83a190f99059ddddd71284cbc9b081 to your computer and use it in GitHub Desktop.
Save cefaijustin/5e83a190f99059ddddd71284cbc9b081 to your computer and use it in GitHub Desktop.
function findDupsMiss(arr) {
let missingNum = [];
let newArr = [];
arr = arr.sort((a, b) => a - b);
let dup = [...new Set(arr)];
for (let y = 1; y < dup.length; y++) {
if (dup[y] - dup[y - 1] != 1) missingNum.push(dup[y] - 1)
}
for (let i = 0; i < arr.length; i++) {
for (let j = i + 1; j < arr.length; j++) {
if (arr[i] === arr[j]) newArr.push(arr[i])
}
}
missingNum.push(newArr);
return missingNum;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment