Skip to content

algorithmsmedium

Merge Maintenance Windows

150 points · 0 solved

The first line is n (1 ≤ n ≤ 2500). Each of the next n lines is start end (0 ≤ start ≤ end ≤ 10⁹), in any order. Merge every pair of windows that overlap or touch (next start ≤ current end) and print the merged windows in ascending order, one start end per line.

4
1 3
2 6
8 10
10 12
1 6
8 12
Learn the technique/learn/algorithms-data-structures

main.py