Merge Intervals
Medium
LC #56
intervalssortingNot attempted yet
Given a list of intervals where each is
[start, end], merge every group of overlapping
intervals and return the resulting non-overlapping
intervals. Intervals that touch ([1,4] and [4,5])
overlap.
Return the intervals in any order.
Example 1
Input: intervals = [[1,3],[2,6],[8,10],[15,18]]
Output: [[1,6],[8,10],[15,18]]
[1,3] and [2,6] overlap, so they become [1,6].
Example 2
Input: intervals = [[1,4],[4,5]]
Output: [[1,5]]
Example 3
Input: intervals = [[4,7],[1,4]]
Output: [[1,7]]
The input is not necessarily sorted.
Constraints
- 1 <= intervals.length <= 10^5
- 0 <= start <= end <= 10^5