I have an array of [start_time, end_time]
time ranges like so:
let timeSegments = [];
timeSegments.push(["02:00", "07:00"])
timeSegments.push(["03:00", "04:00"])
These time segments overlap, since 2AM - 7AM
includes 3AM - 4AM
Likewise:
let timeSegments = [];
timeSegments.push(["14:00", "18:00"])
timeSegments.push(["15:00", "19:00"])
2PM
to 6PM
overlaps with 3PM
to 7PM
.
I'm using the momentjs library, and would like to know a way to determine if my timeSegments array contains any timeSegments that overlap? The timeSegments array can contain at most 10 [start_time, end_time]
pairs. Thanks!
I'd just like to know if any segments overlap (true/false), I don't need to know which of the segments overlap etc.
true
if any times in your array overlap? The overlapping times? The number of overlaps? Is your array always ordered as per your example (earliest->latest) – Preposterous