You are given a stream of non-negative integers
Your task is to implement the Summary Ranges class, where:
Constructor: Initializes the Summary Ranges object with an empty stream.
Add Num(int value): Adds the integer value to the stream.
Get Intervals(): Returns the current summary of numbers as a list of disjoint intervals [start_i, end_i], sorted by start_i.
Note: Each number belongs to exactly one interval. Intervals must merge whenever new numbers connect or extend existing ones, and duplicate insertions should not affect the summary.
Constraints:
value
At most
At most
You are given a stream of non-negative integers
Your task is to implement the Summary Ranges class, where:
Constructor: Initializes the Summary Ranges object with an empty stream.
Add Num(int value): Adds the integer value to the stream.
Get Intervals(): Returns the current summary of numbers as a list of disjoint intervals [start_i, end_i], sorted by start_i.
Note: Each number belongs to exactly one interval. Intervals must merge whenever new numbers connect or extend existing ones, and duplicate insertions should not affect the summary.
Constraints:
value
At most
At most