Solution: Insert Interval
Let's solve the Insert Interval problem using the Merge Intervals pattern.
Statement
Given a sorted list of nonoverlapping intervals and a new interval, your task is to insert the new interval into the correct position while ensuring that the resulting list of intervals remains sorted and nonoverlapping. Each interval is a pair of nonnegative numbers, the first being the start time and the second being the end time of the interval.
Constraints:
-
existing_intervals.length
-
existing_intervals[i].length
,new_interval.length
== 2 -
start time ...
Access this course and 1400+ top-rated courses and projects.