Range Module
Try to solve the Range Module problem.
We'll cover the following
Statement
Design a Range Module data structure that effectively tracks ranges of numbers using half-open intervals and allows querying these ranges. A half-open interval
Implement the RangeModule class with the following specifications:
Constructor(): Initializes a new instance of the data structure.
Add Range(): Adds the half-open interval
to the ranges being tracked. If the interval overlaps with existing ranges, it should add only the numbers within that are not already being tracked. Query Range(): Returns true if every real number within the interval
is currently being tracked, and false otherwise. Remove Range(): Removes tracking for every real number within the half-open interval
.
Constraints:
left
right
At most,Â
calls will be made to Add Range(), Query Range(), and Remove Range().
Examples
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.