FastPrepMinimum Stress Path
Problems/Minimum Stress Path

Minimum Stress Path

Walmart logoWalmart● MediumINTERNOA

Updated Aug 2026

QuestionFunctionExamplesConstraints

Problem statement

You are given a weighted undirected graph with graph_nodes nodes numbered from 1 through graph_nodes. The arrays graph_from, graph_to, and graph_weight describe the graph's edges: edge i connects graph_from[i] and graph_to[i] with weight graph_weight[i].

The stress level of a path is the maximum edge weight on that path.

Return the minimum possible stress level among all paths from source to destination. If no such path exists, return -1. If source = destination, return 0.

Although the endpoint arrays are named graph_from and graph_to, every edge is undirected.

Function

getMinimumStress(graph_nodes: int, graph_from: int[], graph_to: int[], graph_weight: int[], source: int, destination: int) → int

Examples

Example 1

graph_nodes = 4graph_from = [2,2,1,4]graph_to = [1,3,4,3]graph_weight = [100,200,10,20]source = 1destination = 3return = 20

The weighted undirected graph has two branches from node 1 to node 3:

Weighted undirected graph
​​​
​(3)​
200 ↗​↖ 20
(2)​(4)
↖ 100​10 ↗
​(1)​
  1. The path 1 -> 2 -> 3 has stress max(100, 200) = 200.
  2. The path 1 -> 4 -> 3 has stress max(10, 20) = 20.

The minimum possible stress is 20.

Example 2

graph_nodes = 5graph_from = [1,2,1,4,1,5]graph_to = [2,3,4,3,5,3]graph_weight = [10,5,3,2,4,6]source = 1destination = 3return = 3

The path 1 -> 4 -> 3 uses edge weights 3 and 2, so its stress is max(3, 2) = 3. This is lower than the stress of 1 -> 2 -> 3, which is 10, and 1 -> 5 -> 3, which is 6. Therefore, the minimum possible stress is 3.

Source note: This example was added from a new source found on August 3, 2026.

Constraints

  • 1 <= graph_nodes <= 10^5.
  • 1 <= graph_from.length = graph_to.length = graph_weight.length <= 10^5.
  • 1 <= graph_from[i], graph_to[i], source, destination <= graph_nodes.
  • 0 <= graph_weight[i] <= 10^9.

Source note: The first and third images show the same Question 1; the second image preserves the additional constraints and example.

More Walmart Online Assessment questions

  • Largest Team Where Every Pair OverlapsOA · Seen Nov 2026
  • House RobberOA · Seen Sep 2026
  • Maximum Points by Deleting ElementsOA · Seen Sep 2026
  • Distinct Bitwise-OR Scores of Increasing SubsequencesOA · Seen Sep 2026
  • Best Meeting PointOA · Seen Sep 2026
  • Minimum Cost to Make Array EqualOA · Seen Sep 2026
  • K-Capable Model CostsOA · Seen Jun 2026
  • K-Capable Model SelectionOA · Seen Jun 2026
  • Minimum Moves to Equal Candy BarsOA · Seen Oct 2024
  • Find Length of Longest Good SubsequenceOA · Seen Feb 2024

Similar questions at other companies

  • Dijkstra Shortest Paths in a Weighted Undirected GraphVisa · OAVisa interview questions
  • Minimize Path ValuePalantir · OAPalantir interview questions
  • Minimize Path ValueSalesforce · OASalesforce interview questions
  • Cookie Monster Minimum Arrival TimeIntuit · OAIntuit interview questions
  • Minimum Wizard Referral CostAirbnb · OAAirbnb interview questions
  • Minimum Travel Time with Flashing Traffic LightsPeopleStrong · OAPeopleStrong interview questions
  • Shortest Travel Time in a Grid with Traffic LightsWaymo · PHONE SCREENWaymo interview questions
  • Cheapest Flights Within K StopsAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Shortest Paths in a Nonnegative Directed GraphNation with NaMo · PHONE SCREEN
  • Minimum Product Path in a Directed GraphGoogle · ONSITE INTERVIEWGoogle interview questions
All Walmart interview questionsSee Walmart hiring insights
Saved
class Solution {
    public int getMinimumStress(int graph_nodes, int[] graph_from, int[] graph_to, int[] graph_weight, int source, int destination) {
      // write your code here
    }
}
Checking account…