Back to problems

Fuel Station Queue Simulation

Algorithm · Tesla · Medium

A fuel station operates three dispensers: X, Y, and Z. Each dispenser starts with a known initial fuel quantity. A line of N cars waits for fuel; each car requires exactly D liters. A dispenser is considered free when it is not actively serving a vehicle. When a car pulls up to the front of the queue, the following logic governs its actions: The driver may select any dispenser that is currently free. The selected dispenser must hold at least D liters of remaining fuel. If…

Checking your access…