Back to problems

Merge Overlapping Time Windows

Algorithm · ByteDance · Medium

Given a list windows of time intervals, where each interval is written as [start, end), merge all overlapping intervals and return the merged intervals sorted by their start values. The interval [start, end) represents every timestamp t satisfying start <= t < end; as a result, intervals such as [1, 3) and [3, 5) only touch at a single point and do not overlap. Implement the function mergeTimeWindows(windows). The input may be empty, may be unsorted, and may contain…

Checking your access…