Question bank › Queue
Dsa Queue Easy

Train Station Arrival

At a busy train station, trains arrive at designated times and stay for a certain duration. The station can only accommodate one train at a time. Implement a program that manages the train arrivals and calculates how many trains can be served in a given time period. The input consists of multiple lines each containing two integers: the arrival time of the train and its length of stay. The program ends when EOF is reached. Output the total count of trains served within the time period. Example Input: 1 3 2 5 6 3 Example Output: 2

Key concepts

queueschedulingsimulation

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
Part of Praxari's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.