Skip to content

Instantly share code, notes, and snippets.

@santhosh17s
Last active February 21, 2018 09:30
Show Gist options
  • Save santhosh17s/c76e642ceefc7e070e8df235f0d2af97 to your computer and use it in GitHub Desktop.
Save santhosh17s/c76e642ceefc7e070e8df235f0d2af97 to your computer and use it in GitHub Desktop.
Missing Number in Array using JS
var arr = [27,30,23,20,22,25,29,24];
function absent( arr ) {
var mia= [], min= Math.min.apply('',arr), max= Math.max.apply('',arr);
while(min<max){
if(arr.indexOf(++min)== -1) mia.push(min);
}
return mia;
}
absent(arr)
//(3) [21, 26, 28]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment