Compute buffet revenue with capacity and waiting
Company: Upstart
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Technical Screen
Quick Answer: This question evaluates event-driven simulation and state-management skills, including handling customer lifecycle, capacity constraints, FIFO queuing behavior, and revenue aggregation.
Constraints
- 0 <= capacity <= 200000
- 0 <= n = len(prices) <= 200000
- 0 <= m = len(events) <= 200000
- 0 <= prices[i] <= 10^9
- 0 <= events[j] < n
- For each customer, appearances in `events` alternate arrival, leave, arrival, leave, ... starting with arrival