FastPrepFastPrep
Problem Brief

Minimize Path Value

INTERNOA

There is a weighted undirected graph with N nodes and M edges. The stress level of a path between two nodes is defined as the weight of the edge with the maximum value present in the path. Given a source node "source" and a destination node "destination," find a path with the minimum stress level. If no such path exists, report -1.

1Example 1

Input
N = 4, edges = [[1, 2, 100], [2, 3, 200], [1, 4, 10], [4, 3, 20]], source = 1, destination = 3
Output
20
Explanation
Example 1 illustration
There are two paths from node 1 to node 3:
  • The max weighted edge/stress level in path 1 -> 2 -> 3 is 200
  • The max weighted edge/stress level in the path 1 -> 4 -> 3 is 20
  • Return 20, the lower stress level from the second path.

    Constraints

    Limits and guarantees your solution can rely on.

    ๐Ÿ‰๐Ÿ‰
    public int minimizePathValue(int N, int[][] edges, int source, int destination) {
      // write your code here
    }
    
    Input

    N

    4

    edges

    [[1, 2, 100], [2, 3, 200], [1, 4, 10], [4, 3, 20]]

    source

    1

    destination

    3

    Output

    20

    Sign in to submit your solution.