Given a list named intervals, with each entry written as intervals[i] = [start_i, end_i], combine every pair or group of intervals that intersects. Return a list of disjoint intervals whose combined coverage matches all intervals from the input.
The returned intervals may appear in any order.
Note: Two intervals are considered disjoint only when they share no point. For instance, [2, 4] and [5, 7] are disjoint, whereas [2, 4] and [4, 6] overlap.
Example 1:
Input: intervals = [[2,4],[3,6],[8,9]]
Output: [[2,6],[8,9]]
Explanation: [2,4] intersects [3,6], so they become [2,6]; [8,9] remains separate.
Example 2:
Input: intervals = [[4,5],[5,8]]
Output: [[4,8]]
Explanation: Both intervals include the point 5, so they must be merged.
1 <= intervals.length <= 1000intervals[i].length == 20 <= start <= end <= 1000