Company: Tech Mahindra_12thjuly
Difficulty: medium
Delivery Person Rest Time Problem Description A delivery person works for an intercity delivery company whose headquarters is in city 1 . There are N cities, numbered 1 to N , connected by M bidirectional roads. Road i joins cityA and cityB and takes timeC units of time to travel, in either direction. Every city can be reached from city 1 , either directly or through other cities. The delivery person has Q deliveries to make, in the given order. For each delivery they are given a city X and a time limit K . They must leave city 1 , reach city X , and come back to city 1 . They always choose the fastest possible round trip, so that the time left over can be spent resting before the next delivery. For one delivery, let T be the minimum time of a round trip 1 -> X -> 1 : If T <= K , the delivery is made and the rest time is K - T . If T > K , the delivery cannot be made and the rest time is 0 . Compute the rest time of every delivery. Complete the function calculateRestTimes(t