Minimize Path Value
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.
Complete the function leastStressfulPath in the editor below.
leastStressfulPath has the following parameter(s):
int graph_nodes: number of nodesint graph_from[]: one end node for an edgeint graph_to[]: the other end node for an edgeint graph_weight[]: the weights of the edgesint source: the source nodeint destination: the destination node
Returns
int: the value of the least stressful path. If no path exists, return -1.
Note: Even though edge endpoints are called graph_from[] and graph_to[], this is an undirected graph.
Input Format for Custom Testing
The first line contains two space-separated integers graph_nodes and m, the number of nodes, and the number of edges of the graph.
Each of the following m lines contains three space-separated integers a, b, and w meaning there is an edge connecting the nodes a and b of weight w.
The next line contains a single integer, denoting the index of the "source" node.
The next line contains a single integer, denoting the index of the "destination" node.
𑁍ࠬܓ Credit to Rachel and spike!!⋆。˚⋆❀ 🐚🫧𓇼 ˖°
1Example 1

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.