2022-03-27 18:35:17 +08:00
< p > Given an array of < code > intervals< / code > where < code > intervals[i] = [start< sub > i< / sub > , end< sub > i< / sub > ]< / code > , merge all overlapping intervals, and return < em > an array of the non-overlapping intervals that cover all the intervals in the input< / em > .< / p >
< p > < / p >
2023-12-09 18:42:21 +08:00
< p > < strong class = "example" > Example 1:< / strong > < / p >
2022-03-27 18:35:17 +08:00
< pre >
< strong > Input:< / strong > intervals = [[1,3],[2,6],[8,10],[15,18]]
< strong > Output:< / strong > [[1,6],[8,10],[15,18]]
2023-12-09 18:42:21 +08:00
< strong > Explanation:< / strong > Since intervals [1,3] and [2,6] overlap, merge them into [1,6].
2022-03-27 18:35:17 +08:00
< / pre >
2023-12-09 18:42:21 +08:00
< p > < strong class = "example" > Example 2:< / strong > < / p >
2022-03-27 18:35:17 +08:00
< pre >
< strong > Input:< / strong > intervals = [[1,4],[4,5]]
< strong > Output:< / strong > [[1,5]]
< strong > Explanation:< / strong > Intervals [1,4] and [4,5] are considered overlapping.
< / pre >
< p > < / p >
< p > < strong > Constraints:< / strong > < / p >
< ul >
< li > < code > 1 < = intervals.length < = 10< sup > 4< / sup > < / code > < / li >
< li > < code > intervals[i].length == 2< / code > < / li >
< li > < code > 0 < = start< sub > i< / sub > < = end< sub > i< / sub > < = 10< sup > 4< / sup > < / code > < / li >
< / ul >