← problems
#56

Merge Intervals

MediumIntervals

Given an array of intervals where intervals[i] = [start, end], merge all overlapping intervals and return an array of the non-overlapping intervals that cover all the input intervals, sorted by start.

Example

[[1,3],[2,6],[8,10],[15,18]]  => [[1,6],[8,10],[15,18]]
[[1,4],[4,5]]                 => [[1,5]]
Implement
function Merge(intervals: int[][]) -> int[][]

Found a bug? Or annoyed about something in the language? Tell us.

loading editor…