Company: PhonePe

Difficulty: medium

Problem Statement

Cheapest Route Within a Time Budget Problem Description A logistics company operates in a country with n cities numbered 0 through n - 1 , connected by m two-way highways. Highway i joins cities u i and v i and takes t i minutes to drive in either direction. Every city charges an entry fee. Driving into city c costs fee[c] rupees, and the fee is charged every single time the truck enters that city — including the very first city, where the truck starts. A truck must travel from city src to city dest and it must arrive within maxTime minutes (arriving at exactly maxTime minutes is allowed). Among all routes that respect the deadline, report the minimum total fee. The route does not have to be simple — the truck may drive through the same city more than once, paying its fee again each time. If no route reaches dest within the deadline, report -1 . Input Format The first line contains three integers n , m and maxTime . The second line contains n integers — fee[0], fee[1]

More PhonePe OA questionsInterview experiences