Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Maintain a sorted set of disjoint intervals. addRange and removeRange can be performed with time complexity linear to the size of this set; queryRange can be performed with time complexity logarithmic to the size of this set.