The input for this problem is a positive integer
An example of a valid input would be:
Clearly, some of these segments overlap, and can therefore be fused. For example, the segments
You are asked to write a program that reads the segments from the input, and outputs an equivalent series of segments in which all overlapping and touching input segments have been fused. The segments must be printed on the output in ascending order of the lower bounds of the segments. For the above example, the output should thus be
input:
6:[1,5),[2,3),[4,6),[7,8),[8,10),[12,15)
output:
[1,6),[7,10),[12,15)
input:
6:[1,5),[7,8),[8,10),[12,15),[2,3),[4,6)
output:
[1,6),[7,10),[12,15)
input:
10:[1,2),[1,4),[0,5),[0,1),[1,7),[0,0),[2,9),[1,7),[2,7),[1,4)
output:
[0,9)