Insert newInterval into intervals (sorted non-overlapping) and merge if necessary.
Input: intervals = [[1,3],[6,9]], newInterval = [2,5]
Output: [[1,5],[6,9]]
Topics: arrays
Asked by: Google, Meta
Time complexity: O(n). Space complexity: O(n).