This question evaluates proficiency in reasoning about time-interval overlap, event aggregation, and online data structures for streaming interval queries, testing skills in algorithm design and temporal data handling within the Coding & Algorithms domain.
Given delivery intervals (driverId, startTime, endTime) already recorded, implement maxSimultaneousDriverInPast24Hours() that returns the maximum number of distinct drivers who were simultaneously on a delivery at any instant within the window (now−24h, now]. Precisely define "simultaneous" and the interval semantics (open/closed). If multiple times achieve the maximum, optionally also return one such timestamp or the corresponding maximal intervals. Describe an efficient algorithm and data structures that support online inserts from RecordDelivery and queries with strong performance guarantees, and analyze time and space complexity.