Dsa
Queue
Medium
Bus Station Queue Management
A bus station has a limited number of gates and a queue of buses waiting to depart. Each bus takes a certain amount of time at the gate before it can leave. You need to simulate the process and determine when each bus will depart.
Input Format:
- The first line contains two integers, n (number of buses) and m (number of gates).
- The next n lines each contain one integer representing the time taken by each bus at the gate.
Output Format:
- Output n lines, where each line contains the departure time of each bus.
Example Input:
3 2
4
2
3
Example Output:
2
4
7
Key concepts
queuesimulationdata structures
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