Code Room
CodingHardcod-g427
Subject IntervalsLevel Senior–Staff~30 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

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.

Implement
merge_k_schedules(schedules: list[list[list[int]]]) → list[list[int]]
Examples
in[[[[1,3],[6,7]],[[2,4]],[[2,5],[9,12]]]]out[[1,5],[6,7],[9,12]]
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.

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.

Run or narrate your approach, then ask the coach.