Merged Timeline
Merge all overlapping or touching intervals and print the resulting disjoint intervals in increasing order.
Input: the first line has N; the next N lines each have an interval a b (a ≤ b).
Output: the merged intervals, one per line.
Constraints:
- 1 ≤ N ≤ 105
- 0 ≤ a ≤ b ≤ 106
Sample Tests
Input 1
3 1 3 2 5 7 8
Output 1
1 5 7 8
Input 2
1 4 4
Output 2
4 4
Discussion (opens after you solve — no spoilers before)
No comments yet.