At a trading firm like Jane Street, market activity is recorded as time intervals. Given a list of intervals representing active trading windows, merge all overlapping intervals and return the condensed list in ascending order.
Implement a function that takes intervals, a list of lists where each element is [start, end] and start <= end. Return a new list of merged intervals, where any overlapping or touching intervals are combined into a single interval.
Example 1
intervals = [[1,3],[2,6],[8,10],[15,18]][[1,6],[8,10],[15,18]][1,3] and [2,6] overlap, so they merge into [1,6].Example 2
intervals = [[1,4],[4,5]][[1,5]]4, so they are merged.1 <= len(intervals) <= 10^4intervals[i].length == 20 <= start <= end <= 10^6