Google VO Interview Question: Design and Implement an IntervalSet (Union of Ranges)

102 Views
No Comments

Design and implement an IntervalSet, also known as a union of ranges. The IntervalSet should support:

  • Inserting intervals
  • Querying whether a particular value is contained

This problem asks you to design an IntervalSet, i.e. a structure that maintains the union of ranges while supporting interval insertion and membership queries. The key idea is to keep disjoint, merged intervals in an ordered structure, merge overlaps on insert, and answer contains queries efficiently using binary search or a balanced tree. The main challenge is preserving a compact representation of the interval union so both updates and lookups remain fast.

END
 0