The Average Waiting Time interview question is a simulation of a single-chef restaurant. You are given a list of customers, each with an arrival time and the time required to prepare their dish. The chef cooks for one customer at a time in the order they arrive. A customer's waiting time is (finish_time - arrival_time). Your goal is to find the average waiting time for all customers. This Average Waiting Time coding problem focuses on sequential processing.
Apple, Meta, and Google ask this to evaluate your ability to manage state over time. It tests whether you can correctly track the chef's "current available time" and understand how idle time (when no customers are present) affects the timeline.
This follows the Array, Simulation interview pattern. You maintain a variable currentTime representing when the chef will finish the current task. For each customer, the chef starts cooking at max(arrival_time, currentTime).
Customer 1: Arrives at 1, takes 2 mins. Customer 2: Arrives at 2, takes 5 mins.
In simulation problems, always track the "global clock." Before processing an event, advance the clock to the event's start time if the clock is currently behind.
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Watering Plants | Medium | Solve | |
| Count Unhappy Friends | Medium | Solve | |
| Find The First Player to win K Games in a Row | Medium | Solve | |
| Find the Winner of an Array Game | Medium | Solve | |
| Maximum Profit of Operating a Centennial Wheel | Medium | Solve |