Question
You are given `intervals`, a list of non-overlapping intervals [start, end] sorted ascending by start, and a single `new_interval` [start, end]. Insert the new interval and merge as needed so the result remains sorted and non-overlapping. Return the new list. Two intervals overlap (and merge) if they touch — i.e. [1,2] and [2,3] merge into [1,3]. Up to 10^4 intervals; aim for O(n) with a single pass.
insert_interval(intervals: list[list[int]], new_interval: list[int]) → list[list[int]][[[1,3],[6,9]],[2,5]]out[[1,5],[6,9]]State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.