Given a list of intervals [start, end], merge all overlapping intervals and return the result sorted by start.
Input
n 2 (n intervals)start endOutput: the merged intervals, one per line as start end.
4 2 1 3 2 6 8 10 15 18
1 6 8 10 15 18
[1,3] and [2,6] overlap → [1,6].
2 2 1 4 4 5
1 5
Touching endpoints merge.
Run your code against the sample tests, or Submit to run the full suite.