Back to exercises

Merge Intervals

Sort intervals by start, then compare each interval with the current merged tail. Extend the tail end when ranges overlap; otherwise append a new interval.

Coding Exercises Medium O(n log n)

Merge Intervals

Sort intervals by start, then compare each interval with the current merged tail. Extend the tail end when ranges overlap; otherwise append a new interval.

Merge all overlapping intervals and return the condensed list.