Solve the Merge Intervals problem like you would on LeetCode.
Implement merge(intervals), where intervals is a list of [start, end] pairs. Return a new list containing the minimum set of non-overlapping intervals that covers the same ranges. Intervals that touch, such as [1, 3] and [3, 5], should be merged.
def merge(intervals):