Problem · Graph
Find the Path
Learn this problemProblem statement
Given a graph of N nodes named with 1 to N and M bidirectional weighted edges. Find the path from 1 to N such that weight of maximum in the path is minimum and the number of edges in path won't exceed K.
Function
findThePath(N: int, edges: int[][], K: int) → intExamples
Example 1
N = 4edges = [[1, 2, 4], [1, 3, 2], [2, 4, 5], [2, 3, 6]]K = 3return = 5Note: I'm more than happy to make modifications if anything in the input seems incorrect. You can reach me in our Discord group! 😊
Possible routes from 1 to 4 is [1->2->3, 1->3->2->4]
As the maximum in path 1 -> 2 -> 4 is 5 on the edge 2->4, while in 1->3->2->4 is 6 at edge 3->2.