Range Module
A Range Module is a module that tracks ranges of numbers. Your task is to design and implement the following interfaces in an efficient manner.
addRange(int left, int right)
Adds the half-open interval
[left, right)
, tracking every real number in that interval. Adding an interval that partially overlaps with currently tracked numbers should add any numbers in the interval[left, right)
that are not already tracked.
queryRange(int left, int right)
Returns true if and only if every real number in the interval
[left, right)
is currently being tracked.
removeRange(int left, int right)
Stops tracking every real number currently being tracked in the interval
[left, right)
.
Example 1:
Note:
A half open interval[left, right)
denotes all real numbersleft <= x < right
.
0 < left < right < 10^9
in all calls toaddRange, queryRange, removeRange
.
The total number of calls toaddRange
in a single test case is at most1000
.
The total number of calls toqueryRange
in a single test case is at most5000
.
The total number of calls toremoveRange
in a single test case is at most1000
.
Solution
Last updated