Reliability algorithms
Overlapping maintenance windows
Combine overlapping or touching maintenance windows into a minimal list for a status page.
In production
Overlapping maintenance windows double-book change freezes. Merging them wrong leaves gaps or invents coverage.
What it must return
Merge overlapping or touching intervals into a minimal sorted list of disjoint windows.
- Each window is [start, end] with start <= end. Input may be unsorted. Touching windows merge. Return merged windows in ascending start order.
- Do not mutate input values. Use the Python standard library only.
Edge cases
- Sort a copy by start time.
- Compare each interval to the end of the current merged interval.
- Do not mutate the caller's list.
Signature
merge_windows(windows)Hints
Second hint
A partial sketch
The reference solution opens after the last hint.
Loading editor…
Overlap and touch
windows
[
[
5,
8
],
[
1,
3
],
[
3,
6
],
[
10,
12
]
]Expected
[
[
1,
8
],
[
10,
12
]
]Each run uses a fresh Python runtime in this browser, with a 3-second limit and a Stop button. The first run downloads the runtime. 0 of 10 in Reliability algorithms passed in Python on this device.