Merge k schedules
Your task
You are given k lists of intervals; within each list the intervals are sorted by start and are pairwise disjoint (each list represents a person's busy schedule). Merge all k schedules into a single list of disjoint busy intervals sorted by start, merging any that overlap or touch (touching means one ends exactly where another begins). Use a k-way merge with a heap rather than concatenating and re-sorting. Total intervals across all lists is up to 10^5. Each interval is [start, end] with start <= end. Return the merged list.
Examples
merge_k_schedules(schedules: list[list[list[int]]]) -> list[list[int]]Example 1
Input
merge_k_schedules([[[1, 3], [6, 7]], [[2, 4]], [[2, 5], [9, 12]]])Output
[[1, 5], [6, 7], [9, 12]]