Company: Salesforce_26july
Difficulty: medium
Minimum Journey Length Problem Description A traveling salesperson lives in a country that has road_nodes houses and m roads. The i th road runs from house roads_from[i] to house roads_to[i] and has a length of roads_weight[i] . The roads are directional, meaning it is not possible to travel from house roads_to[i] to house roads_from[i] using the same road. For each house x ( 1 ), find the minimum length of a journey that starts and ends at house x . If no such path exists for a particular house x , return 0 for that house. Note: There are no multiple roads between 2 houses. There can be a road that starts and ends at the same house. All houses may or may not be connected. Examples Example 1: Input: road_nodes = 4 m = 4 roads_from = [1, 2, 3, 3] roads_to = [2, 3, 1, 4] roads_weight = [14, 23, 14, 30] Output: [60, 60, 60, 0] Explanation: The shortest path for every node is as follows: For x = 1, the path is 1 -> 2 -> 3 -> 1, so the path length is 60. For x = 2, the path is 2 -> 3 -> 1 -