Fundamentals/Real-World Queue Examples
← PrevNext →
A single FIFO printer processes jobs as they arrive. Given arrivals as [time, jobName] sorted by arrival time, and a parallel array serviceTime[i] of how long each job takes to print, compute the time each job finishes printing. The printer starts idle at time 0. If the printer is idle when a job arrives, it starts immediately; otherwise the job waits in the queue until the printer is free. Return an array of [jobName, finishTime] in arrival order.