Dsa
Queue
Warm-up
Network Packet Delay
A network router processes packets one by one. Each packet has an arrival time and a processing duration. If a packet arrives while the router is busy, it waits in a queue. A packet starts processing as soon as the router is free and its arrival time has passed. Calculate the total wait time for all packets combined.
Example:
Input:
2
0 5
2 3
Output: 3
(Explanation: P1 arrives at 0, finishes at 5. P2 arrives at 2, must wait until 5 to start. Wait = 5 - 2 = 3.)
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