Merge Intervals
Asked in the Round 2: Technical / DSA stage.
Implement merge_intervals(intervals). The input is an array of integer pairs [start, end], where start <= end. Return an array containing the minimum set of non-overlapping intervals that covers the same ranges. Sort the intervals by start value before merging. Intervals that overlap or touch, such as [1, 3] and [3, 5], must be merged.
def merge_intervals(intervals):