A calendar holds sorted, non-overlapping busy intervals [start, end]. Insert a new booking and merge any overlaps, in one linear pass, without re-sorting.
Implement insert_interval(intervals, new). Intervals that touch (end == start) merge. Don't modify the input.
Then implement free_slots(intervals, day_start, day_end, min_length=1): the gaps of at least min_length between day_start and day_end, given busy intervals that may overlap and be unsorted.