Missing Num

[Solved] Missing Num | Php - Code Explorer | yomemimo.com
Question : missing num

Answered by : repulsive-ray-7sa6594s77wj

const findMissing = num => { const max = Math.max(...num); // Will find highest number const min = Math.min(...num); // Will find lowest number const missing = [] for(let i=min; i<= max; i++) { if(!num.includes(i)) { // Checking whether i(current value) present in num(argument) missing.push(i); // Adding numbers which are not in num(argument) array } } return missing;
}
findMissing([1,15]);

Source : https://stackoverflow.com/questions/37277897/javascript-find-missing-number-in-array | Last Update : Mon, 30 May 22

Answers related to missing num

Code Explorer Popular Question For Php