Dsa
Queue
Medium
Queue Simulation for Customer Service
You are tasked with simulating a customer service queue in a bank. You will be given a sequence of customer arrival times and their service times. Your goal is to determine the total time when all customers have been served. Customers are served in a FIFO manner.
Input Format:
- The first line contains an integer N (1 <= N <= 1000), the number of customers.
- The next N lines each contain two integers: arrival_time (0 <= arrival_time <= 10000) and service_time (1 <= service_time <= 1000).
Output Format:
- A single integer representing the total time when all customers have been served.
Example:
Input:
5
0 10
2 5
4 7
8 3
9 6
Output:
21
Key concepts
queuesimulationorder
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now