Dsa
Queue
Medium
Print Job Scheduler
You are developing a print job scheduler. Print jobs are processed in the order they are received (FIFO). Each job has a specific ID and a timeout after which it should no longer be processed. Your task is to simulate the scheduler, processing print jobs and removing those that have timed out. If a job times out, you should print 'timeout <job_id>'. For each job processed, print the job ID.
Input Format:
- The first line contains an integer n (1 <= n <= 1000), the number of jobs.
- The second line contains an integer t, the timeout duration.
- The next n lines contain job IDs.
Output Format:
- Print the job IDs for successful processing and denote timeouts.
Example:
Input:
5
3
job1
job2
job3
job4
job5
Output:
job1
job2
timeout job3
timeout job4
timeout job5
Key concepts
queuefifoscheduling
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