Dsa
Queue
Warm-up
The Shared Office Printer
An office has a single printer that processes documents in the order they are sent. Each document has a name and a page count. The printer takes 1 second to print 1 page. Given a list of documents in the queue and a target document name, calculate how many seconds the target document has to wait before it starts printing. Assume the printer starts at time 0.
Example:
Input:
3
DocA 10
DocB 5
DocC 8
DocB
Output: 10
(Explanation: DocA takes 10 seconds. DocB starts immediately after DocA finishes.)
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