Hey, I'm Steven Mercatante and I build things for the web.
I'm a full stack software engineer with over 15 years of experience building websites, mobile apps, APIs, CMSs, and ETL pipelines.
functionminMinMax(arr){// Sorting `arr` lets us easily select the min and max valuesarr.sort((a,b)=>a-b)constmin=arr[0]constmax=arr[arr.length-1]// Starting at the `min` number, search between // `min` and `max` until you find a value that's not in `arr`letminimumAbsent=nullfor(leti=min;i<max;i++){if(!arr.includes(i)){minimumAbsent=ibreak}}return[min,minimumAbsent,max]}minMinMax([-1,4,5,-23,24]);//[-23, -22, 24]// minMinMax([1, 3, -3, -2, 8, -1]); //[-3, 0, 8]// minMinMax([2, -4, 8, -5, 9, 7]); //[-5, -3, 9]
Runnable example:
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Runnable example: