Implement the merge algorithm. core idea: after sorting by start, two consecutive intervals overlap if and only if the second starts before the first ends.
Edge cases: - Single interval: return as-is - All overlapping: merge into one - None overlapping: return sorted list The greedy approach works because sorting ensures we process intervals left to right.
Once you've decided an interval is separate, no future interval can merge with earlier ones. Time: . Space: .