Problem · Intervals
Merge Intervals
Learn this problemProblem statement
Given a collection of time intervals [start, end], merge and return the overlapping intervals sorted in ascending order of their start times.
Function
getMergedIntervals(intervals: int[][]) → int[][]Examples
Example 1
intervals = [[7, 7], [2, 3], [6, 11], [1, 2]]return = [[1, 3], [6, 11]]The interval [1, 2] merges with [2, 3] while [7, 7] merges with [6, 11]. There are no more overlapping intervals. The answer is [[1, 3], [6, 11]].