Last active
September 7, 2018 01:24
-
-
Save cefaijustin/5e83a190f99059ddddd71284cbc9b081 to your computer and use it in GitHub Desktop.
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 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