Company: IBM
Difficulty: medium
Question 2: UDP Network Protocol Implement a prototype of a UDP network protocol. There is a 2D array of size n x 2 , requests . At time t = requests[i][0] , requests[i][1] packets are to be sent over the network. The network can hold at most max_packets packets in the pipeline. It delivers data to the client at rate packets per second. That is, every second, rate packets are removed from the queue and delivered to the client. If the number of packets exceeds max_packets at any time, the packets remaining at that time are dropped. Given the array requests and the integers max_packets and rate , find the total number of packets that are dropped. Input Format The first line contains an integer n , the number of elements in requests . Each of the n lines contains two space-separated integers requests[i][0] and requests[i][1] . The next line contains an integer max_packets , the capacity of the pipeline. The last line contains an integer rate , the per-second transmission rate. Output Form