Dsa
Queue
Easy
Customer Service Waiting Time
A customer service desk processes one customer at a time. You are given a list of customer service times. Calculate the total waiting time for all customers in the queue. The waiting time for each customer is the sum of the service times of all preceding customers.
Input Format:
- The first line contains an integer N (1 ≤ N ≤ 1000), the number of customers.
- The next N lines contain an integer T (1 ≤ T ≤ 20), the service time for each customer.
Output Format:
- Output the total waiting time.
Example:
Input:
4
3
2
5
1
Output:
15
Key concepts
queuesimulation
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