Algorithm · Google · Medium
(This problem is a variation of the classic Meeting Rooms II. If you haven't solved that one yet, it's a good idea to tackle it first.) You are given a collection of closed intervals on the integer number line. Design a data structure that can efficiently answer, over an arbitrary number of queries, how many of those intervals cover a given point. An inclusive interval [l, r] covers a point x whenever $$l \le x \le r$$. Implement the IntervalCounter class with the following…
Checking your access…