85. Insert Interval

intervals is sorted by start and has no overlaps. Insert newInterval, merging where needed, and return the result (still sorted, without overlaps).

Example 1

Input: intervals = [[1,3],[6,9]], newInterval = [2,5]
Output: [[1,5],[6,9]]

Example 2

Input: intervals = [[1,2],[3,5],[6,7],[8,10],[12,16]], newInterval = [4,8]
Output: [[1,2],[3,10],[12,16]]
Hint 1

Three phases: intervals ending before the new one, intervals overlapping it, and the rest.

Intervals