Merge overlapping intervals
Each delivery slot is an interval [start, end]. Overlapping or touching
slots should be merged into one. Sort the slots by start. Walk through
them keeping the current merged slot: if the next slot starts at or before
the current one ends, extend the current end to the larger of the two
ends; otherwise the current slot is finished, so record it and start a new
one from the next slot.
Write merge_slots(slots) that returns the merged slots as a list of
[start, end] lists, sorted by start. Do not change the input.
merge_slots([[1, 3], [2, 6], [8, 10], [15, 18]]) -> [[1, 6], [8, 10], [15, 18]]
merge_slots([[1, 4], [4, 5]]) -> [[1, 5]]
def merge_slots(slots):
...