bookings[i] = [start, end] occupies the time from start to end, both ends included. Bookings may overlap.
Combine every group of overlapping bookings: two segments that share at least one point (including when one ends exactly where the other begins) become a single segment. Return the resulting non-overlapping segments sorted by start. Together they must cover exactly the same time as the original bookings.bookings=[[9, 12], [1, 4], [3, 5], [12, 14]] → [[1, 5], [9, 14]]
[1, 4] and [3, 5] overlap and become [1, 5]. [9, 12] and [12, 14] touch at 12, so they merge into [9, 14] as well. The result is sorted by start.
bookings=[[2, 10], [3, 4], [6, 7]] → [[2, 10]]
Both short bookings lie entirely inside [2, 10].
bookings=[[5, 6], [0, 2]] → [[0, 2], [5, 6]]
The bookings do not overlap, so they stay as they are, just ordered by start.
bookings ≤ 10⁴bookings[i] has exactly two numbersstart ≤ end ≤ 10⁴bookings=[[9, 12], [1, 4], [3, 5], [12, 14]]
[[1, 5], [9, 14]]
Run checks the first 3 tests in your browser. Submit checks all 94 tests on the server, hidden ones included.