Algorithm to compact / simplify scales? – Exchange of computer battery

I'm trying to create an algorithm in C # that gives a compact list of ranges (segments):

Contribution:
[1, 3], [2, 6]

Exit:
[1, 6]

Contribution:
[1, 2], [2, 3]

Exit:
[1, 3]

Contribution:
[1, 2], [4, 6], [2,4]

Exit:
[1, 6]

To better visualize the problem, this problem is similar to this one:
if you have a shop that opens from Monday to Tuesday and of Tuesday to Sunday, so you can say that your shop opens from Monday to Sunday. This is what the algorithm needs to do: simplify the ranges and give the minimal set of merged ranges.

I am absolutely lost on how to approach this problem. Thank you in advance.