← All problems

Merge Intervals

Medium arrayssortinggreedy LeetCode ↗
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.

Hints (0/3 revealed)

Log in to reveal hints progressively.

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.