56_Merge Intervals
Last updated
Last updated
[Medium][Array, Sort]
Given a collection of intervals, merge all overlapping intervals.
Example 1:
Example 2:
Idea:
Sort the intervals by the starting number.
Compare if next starting number is less than or equal to previous ending number.
If previous ending >= next starting, merge together
If previous ending < next starting, keep splitted.
Time Complexity:
Space Complexity: