← All problems
Merge Intervals
Given an array of intervals [start, end], merge all overlapping intervals and return the minimal set of non-overlapping intervals covering the same ranges. Intervals that only touch at endpoints count as overlapping.
Complexity
Time O(n log n), Space O(1) excluding output
Common pitfalls
- Not sorting first
- Wrong overlap condition (use start <= cur_end)
Your solution
Log in to save your code and track progress.