QuestionGiven an array ofintervalswhereintervals[i] = [starti, endi], merge all overlapping intervals, and returnan array of the non-overlapping intervals that cover all the intervals in the input.Example 1:Input: intervals = [[1,3],[2,6],[8,10],[15,18]]
Output: [[1,6],[8,10],[15,18]]
Explanation: Since intervals [1,3] and [2,6] overlap, merge them into [1,6].AlgorithmFor this question, we need to sort the array intervals by their start.(interval[0]) byfull sort.Why do this? For example, after sorting, all the start will have an order, and if the next one's start is larger than the previous on
...
继续阅读
(7)