Range Module
Design a relay coverage tracker that manages half-open intervals [left, right) on the integer line. The tracker starts empty and supports three operations:
addRange(left, right)adds the half-open interval[left, right)to the tracked set, merging overlapping or adjacent intervals.queryRange(left, right)returnstrueif every integer in[left, right)is currently tracked, otherwisefalse.removeRange(left, right)removes the half-open interval[left, right)from the tracked set, splitting existing intervals when necessary.
This is the original Google Range Module problem (LeetCode 715). All intervals are half-open, left < right, and 0 <= left < right <= 10^9. The constructor RangeModule() creates an empty tracker. addRange and removeRange return nothing, while queryRange returns a boolean.
Examples
Input: [["RangeModule","addRange","queryRange"],[[],[10,20],[10,14]]]
Output: [null,null,true]
Input: [["RangeModule","addRange","queryRange","removeRange","queryRange"],[[],[10,20],[10,14],[14,16],[10,14]]]
Output: [null,null,true,null,true]
Hints
Keep tracked intervals sorted, disjoint, and merged; half-open adjacency `[a,b)` and `[b,c)` should merge on add.
`queryRange` is true only if a single stored interval satisfies `l <= left && right <= r` after merging.
`removeRange` may split one interval into two: keep `[l, left)` and `[right, r)` when overlapping.
Related Problems
Range Module
Design a relay coverage tracker that manages half-open intervals `[left, right)` on the integer line. The tracker starts empty and supports three operations: