Code RoomMerge overlapping intervals
MediumPrep Room Coding #655

Merge overlapping intervals

CodingAlgorithms & data structuresEntry–Mid~14 min

A parking app records reservations for one space as [start, end] hour pairs, treated as closed ranges. Reservations that overlap or touch — one ends exactly when another starts — belong to the same continuous occupied block. Given an unsorted list, merge it and return the occupied blocks as [start, end] pairs sorted by start. Example: [[8,10],[1,3],[2,6]] becomes [[1,6],[8,10]].

Implement
merge_reservations(reservations: list[list[int]]) → list[list[int]]
Examples
in[[[8,10],[1,3],[2,6]]]out[[1,6],[8,10]]
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 14 min
InputExpectedGot
[[[8,10],[1,3],[2,6]]][[1,6],[8,10]]not run yetsample