#LC 56•Intervals & Greedy•Medium
Merge Intervals
Merge all overlapping intervals and return the resulting non-overlapping intervals.
Understand the problem
Merge all overlapping intervals and return the resulting non-overlapping intervals.
Example 1
Input: {"intervals": [[1, 3], [2, 6], [8, 10], [15, 18]]}
Output: [[1, 6], [8, 10], [15, 18]]
Follow the trace to see how the algorithm reaches this result.
Constraints
- Use the input format shown in the example.
Think first
What information should you keep so you can solve the next step efficiently?
Pattern tags:SortingIntervals