Hard
Merge Overlapping Intervals
Read n intervals
start end. Store them as tuples, sort them, and merge any that overlap or touch. Print the merged intervals one per line.Input
n, then n lines.
Output
Lines.
Sample 1
Input
4 1 3 2 6 8 10 15 18
Output
1 6 8 10 15 18
Sample 2
Input
2 1 4 4 5
Output
1 5
Output appears here