Compute 95th-percentile call concurrency
Company: Meta
Role: Data Scientist
Category: Coding & Algorithms
Difficulty: Medium
Interview Round: Onsite
Quick Answer: This question evaluates a candidate's ability to design scalable algorithms for computing the 95th-percentile of per-minute concurrent calls over a 24-hour window, testing competencies in streaming/event aggregation, de-duplication, percentile computation, and managing time and memory constraints.
Constraints
- Intervals are [start, end) UNIX-second pairs.
- windowStart and windowEnd define the half-open analysis window.
- Identical (start, end) intervals are counted once.
- A minute bucket is counted if an interval overlaps any timestamp in that minute.
Examples
Input: ([[0,60],[0,120],[60,180]], 0, 180)
Expected Output: 2
Explanation: The three minute buckets have counts 2, 2, and 1.
Input: ([[0,60],[0,60],[30,60],[60,120]], 0, 120)
Expected Output: 2
Explanation: Duplicate intervals are ignored and end boundaries are half-open.
Input: ([[600,660]], 0, 180)
Expected Output: 0
Explanation: Intervals outside the window contribute nothing.
Input: ([[0,600],[120,300],[240,480],[540,660]], 0, 600)
Expected Output: 3
Explanation: Overlapping intervals are accumulated with a sweep line.
Hints
- Clip intervals to the requested window before bucketing.
- Use a difference array over minute buckets, then sort the counts for nearest-rank percentile.