Company: Uber
Difficulty: medium
Alex needs to run two errands before going to school, and they must be completed in a specific order. Given a city represented as an undirected graph, determine the fastest route from Alex's starting point, through the two errand locations, and finally to school. The city is represented as a graph with nodes labeled from 1 to g_nodes . Alex always starts at node 1, and the school is always at node g_nodes . You are given the starting nodes ( g_from ), ending nodes ( g_to ), and travel times ( g_weight ) for all roads in the city. Example g_nodes = 5 g_from = [1, 2, 3, 4, 5, 3] g_to = [2, 3, 4, 5, 1, 5] g_weight = [9, 11, 6, 1, 4, 10] x = 2 y = 3 Possible routes: 1 → 2 → 3 → 5: Total time = 9 + 11 + 10 = 30 1 → 2 → 3 → 4 → 5: Total time = 9 + 11 + 6 + 1 = 27 The shortest route takes 27 time units. Note: Alex can visit any node multiple times if needed. Function Description Complete the function minCostPath in the editor below. The function must return the time it takes to travel the sho