Company: Tech Mahindra
Difficulty: medium
Delivery Person Rest Time Problem Description A delivery person works for an intercity delivery company whose headquarters are in city 1. For each delivery, the delivery person has to go to another city and then return to city 1. After each delivery, the delivery person likes to maximize their rest time so that they can get ready for the next delivery. Therefore, the delivery person tries to locate the minimum distance between city 1 and the city where the delivery needs to be made. There are N cities, numbered 1 to N, connected by M bidirectional roads such that every city is connected to city 1 either directly or via another city. The delivery person is given a list of M combinations of two cities [A, B] and the time C needed to reach city A from city B. To deliver Q deliveries in the order in which they have been assigned, the delivery person is given the name of the city X, and the time allowed for the delivery (K) to be completed and the driver then returns to the headquarters. If