I have an array of time ranges [start_time, end_time], for example:
let timeSegments = [];
timeSegments.push(["02:00", "07:00"])
timeSegments.push(["03:00", "04:00"])
These time segments overlap because it 2AM - 7AMincludes3AM - 4AM
Similarly:
let timeSegments = [];
timeSegments.push(["14:00", "18:00"])
timeSegments.push(["15:00", "19:00"])
2PMbefore 6PMoverlaps with 3PMbefore 7PM.
I am using the momentjs library and would like to know a way to determine if my timesSegments array contains any time intervals that overlap? The timesSegments array can contain no more than 10 [start_time, end_time]pairs. Thank!
I would like to know if any segments overlap (true / false), I don’t need to know which segment overlaps, etc.
source
share