Suppose I have an array of numbers (which indicate the minutes when cron jobs should run):
let arr = ['21', '23', '25', '59', '10']
I want to insert a new number into this array arr, but I want to make sure that it's furthest away from any two numbers that already exist in this spectrum.
Intuitively I can say that it should be somewhere around 44 but how do I program that into an algorithm?
I know the question is a bit general, but it is very useful for scheduling cronjobs automatically, so that they don't overlap, and I don't even know where to start.
Maybe you heard of a similar problem and a possible solution? Or a Node.Js module that does something similar?