How do you find the missing number in a given integer array of 1 to 100?
This is Aaron's attempt at solving this common computer programming interview question.
Aaron solved this without Googling for an answer and he understands that there may be simpler or more elegant methods to solve this but wanted to provide an authentic answer.
Aaron solved this without Googling for an answer and he understands that there may be simpler or more elegant methods to solve this but wanted to provide an authentic answer.
var num_array = new Float64Array([7, 6, 5, 4, 3, 100]);
console.log(is_missing(8, num_array));
function is_missing(num_find, num_array){
num_array = num_array.sort();
for(const [index, num_current] of num_array.entries()){
if(num_current < num_find && num_array[index + 1] > num_find || (index === 0 && num_find < num_current)){
return true;
break;
}
if (index === num_array.length - 1 || num_current === num_find){
return false;
break;
}
}
}