You are given a list of integer intervals intervals, where each interval is represented as [start, end] (inclusive), and start <= end.
Two intervals may overlap or touch (e.g., [1,3] and [4,6] touch if you consider integers, because there is no missing integer between 3 and 4). Your task is to find all gaps (missing ranges) between the covered portions of the number line.
More precisely:
minCovered
be the smallest integer covered by any interval, and
maxCovered
be the largest integer covered by any interval.
[minCovered, maxCovered]
that are
not covered
by the union.
Return the gaps as a list of disjoint intervals [gapStart, gapEnd] (inclusive), sorted by gapStart.
[[1,3],[7,10],[2,4]]
[1,4] ∪ [7,10]
[1,10]
are
[[5,6]]
[[5,6]]
[]
.
1 <= len(intervals) <= 2e5