Skip to interview prep
Apexed
Problem list120 / 143

120. Find Uncovered Maintenance Time

MediumIntervals

A maintenance timeline is the half-open interval [start, end). Coverage is a list of possibly overlapping or unsorted half-open intervals.

Return every maximal nonempty uncovered interval as [from, to] in ascending order. Ignore coverage outside the timeline. Touching coverage intervals leave no gap between them.

Example 1

Input: start = 3, end = 12, coverage = [[8,10],[0,4],[5,7],[7,8],[11,20]]
Output: [[4,5],[10,11]]

Example 2

Input: start = 2, end = 8, coverage = [[2,8],[3,5]]
Output: []

Constraints

  • At most 100,000 coverage intervals. All endpoints are integers in [0, 10⁹].
  • Each start is less than or equal to its end.

Tab indents · Ctrl/⌘ + Enter runs · Esc then Tab leaves the editor

Run checks these cases; the expected output comes from the reference solution. Submit judges all 6 hidden and sample tests.

Code runs in an isolated browser sandbox. Progress and submissions are saved on this device.

Find Uncovered Maintenance Time — coding interview practice — Apexed