Google | Phone Screen L3| India
Anonymous User
639
May 02, 2025
May 02, 2025
I got this question in my Google TPS today
Implement a class that acts as a union of ranges. The class should allow to
Insert ranges into the class.
Query the class to check if a particular point is in any of the inserted ranges.
Example:
Ranges Inserted:
2-5
3-5
9-13
Points Queried
0 -> False
2 -> True
10 -> True
I told him about the log(n) for insert and log(n) for query but he kept saying try to figure about querying in O(1) . So I have him many approaches and at last i coded using visited array marking them true and querying to check if its visited or not .
Looks like I failed the interview 🥲
Comments (3)


