medium

Merge Intervals

Given a collection of closed intervals, merge every group of overlapping intervals and return the resulting non-overlapping intervals that cover the same points.

Constraints
  • 1 ≤ intervals.length ≤ 10^4
  • 0 ≤ start ≤ end ≤ 10^4
Examples
in: intervals = [[1,3],[2,6],[8,10],[15,18]]
out: [[1,6],[8,10],[15,18]]

Code it yourself

Solve in
Test execution is not yet available for this exercise.Practice journal →Draft saved in this browser.
Hints:
Which approach applies?

Choose an approach to check your pattern recognition, or reveal the discussion when you need help.