Problem · Graph

Find the Path

HardLinkedInFULLTIMEOA

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.

Examples
01 · Example 1
N = 4
edges = [[1, 2, 4], [1, 3, 2], [2, 4, 5], [2, 3, 6]]
K = 3
return = 5
Note: 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.
More LinkedIn problems
drafts saved locally
public int findThePath(int N, int[][] edges, int K) {
  // write your code here
}
N4
edges[[1, 2, 4], [1, 3, 2], [2, 4, 5], [2, 3, 6]]
K3
expected5
sign in to submit