Everything works well, but I would add a couple of tests.
First: an example of overlapped intervals.
The second: the intervals swapped.
Otherwise, at the moment there is no need to check for duplication, nor to sort the final array.
Created at: 2018/12/12 11:39; Updated at: 2018/12/12 19:46
The question is resolved.