Cloze

Insert Interval

Merge as you scan · O(n) time, O(n) space · LeetCode ↗

intervals are pairs of start and end, sorted by start, with none overlapping. Add newInterval, merging whatever it overlaps, and return the list, still sorted. Intervals that only touch at an end overlap.