You are given non-overlapping intervals sorted by start, plus one new interval. Insert the new interval and merge as needed so the result stays sorted and non-overlapping.
Input
n 2start endOutput: the resulting intervals, one per line.
2 2 1 3 6 9 2 5
1 5 6 9
5 2 1 2 3 5 6 7 8 10 12 16 4 8
1 2 3 10 12 16
The new [4,8] swallows [3,5], [6,7], [8,10].
Run your code against the sample tests, or Submit to run the full suite.