Merge intervals (LeetCode 56).
Asked in the Round 1 (DSA, HackerRank) stage. It was the only coding problem in a round otherwise focused on Java and DB theory.
Given intervals, a list of [start, end] integer pairs, return a new list containing all overlapping intervals merged. Sort the result by start time. Intervals that touch, such as [1, 4] and [4, 5], should be merged.
def merge(intervals):