52. Merge Intervals
MediumIntervals
Given an array of intervals where intervals[i] = [starti, endi], merge all overlapping intervals and return an array of the non-overlapping intervals that cover all the intervals in the input. Two intervals [a, b] and [c, d] overlap if a <= d and c <= b. For example, [[1,3],[2,6],[8,10],[15,18]] merges to [[1,6],[8,10],[15,18]].
Examples
Input: [[1,3],[2,6],[8,10],[15,18]]
Output: [[1,6],[8,10],[15,18]]
Explanation: Public test case for Merge Intervals
Constraints
- 1 <= intervals.length <= 10^4
- intervals[i].length == 2
Loading...
Run checks all cases above. Submit evaluates all test cases.