715. Range Module
Practice Range Module for free on NudgeCode: Hard, Binary Search pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.
Design a structure that tracks which real numbers are covered, using half-open intervals [left, right).
addRange(left, right)starts tracking every number in[left, right). Parts that are already tracked stay tracked.queryRange(left, right)returnstrueif every number in[left, right)is currently tracked.removeRange(left, right)stops tracking every number in[left, right).
Each test is a list of operations and their arguments; the expected output lists what each call returns (null for the constructor and for calls that return nothing).
Example
["RangeModule","addRange","removeRange","queryRange","queryRange","queryRange"]
[[],[10,20],[14,16],[10,14],[13,15],[16,17]]
-> [null,null,null,true,false,true]
Constraints
- 1 <= left < right <= 10^9
- Up to 10^4 calls in total