37. Compress Missing Trace Sequences
EasyEvent streams
The expected sequence numbers are all integers from first inclusive to stop exclusive. Observed is a sorted list of distinct expected numbers that arrived.
Return the missing numbers as the fewest possible consecutive inclusive [start, end] ranges, in ascending order. A singleton is [number, number].
Example 1
Input: observed = [3,4,8], first = 2, stop = 11 Output: [[2,2],[5,7],[9,10]]
Example 2
Input: observed = [], first = 0, stop = 1000000000 Output: [[0,999999999]]
Constraints
0 ≤ first ≤ stop ≤ 10⁹At most 100,000 observed values, all in [first, stop). Do not enumerate unobserved values individually.