Insert interval into calendar
A scheduling assistant stores a person's calendar as busy blocks [start, end] in minutes — closed ranges, non-overlapping, sorted by start. A new busy block arrives. Add it to the calendar, merging it with every existing block it overlaps or touches, and return the updated calendar sorted by start. Example: calendar [[60,90],[150,180]] plus block [85,120] becomes [[60,120],[150,180]].
Implement
insert_busy_block(calendar: list[list[int]], block: list[int]) → list[list[int]]Examples
in
[[[60,90],[150,180]],[85,120]]out[[60,120],[150,180]]What a strong answer looks like
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.
0:00 of about 15 min
solution.py
InputExpectedGot
[[[60,90],[150,180]],[85,120]][[60,120],[150,180]]not run yetsample