Merge Intervals
LeetCode 56 • Medium • Intervals
Given an array of intervals where intervals[i] = [start, end], merge all overlapping intervals and return the non-overlapping intervals.
TimeO(n log n)sort + linear scan
SpaceO(n)result list
Index: —
Current: —
Result: —
Input
Current
Merged
Result
Current
—
Result
—
Ready
Press Play. Sort by start, then scan: if next start ≤ current end, merge; else add new interval.