Dsa
Queue
Warm-up
Queue Printer
You are tasked with simulating a simple printer queue. Users can add print jobs to the queue, and we need to process these jobs in the order they were received. Each print job has a unique ID and a string message. When the job is completed, the message should be printed. Implement a program that reads a list of print jobs and prints them in the order they arrive.
Input format:
- The first line contains an integer n (1 ≤ n ≤ 100) - the number of print jobs.
- The following n lines each contain a print job in the format "<job_id> <message>".
Output format:
- For each job, print its message on a new line, in the order they were given.
Example:
Input:
3
1 Document1.pdf
2 Document2.pdf
3 Document3.pdf
Output:
Document1.pdf
Document2.pdf
Document3.pdf
Key concepts
queuestring manipulation
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