Description
Solutions
Minimize Path Value
🤘 INTERN

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.

Example 1:

Input:  N = 4, edges = [[1, 2, 100], [2, 3, 200], [1, 4, 10], [4, 3, 20]], source = 1, destination = 3
Output: 20
Explanation:
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:
      🍉🍉
    Thumbnail 0

    Testcase

    Result
    Case 1

    input:

    output: