Reported August 2026
Walmartunion find

Minimum Stress Path

Reported by candidates from Walmart's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Walmart OA. Under 2s to a working solution.
Founder's read

Walmart reportedly put Minimum Stress Path in front of candidates in August 2026, and the trap is hiding in the wording. The arrays say graph_from and graph_to, but every edge is undirected. Miss that and your traversal quietly returns -1 on inputs that have an answer. This is a minimax path problem on a graph with up to 10^5 nodes and edges, so brute-force path enumeration is dead on arrival. If you've got an OA invite and 48 hours, learn the bottleneck-path trick below. StealthCoder sits invisibly as a backup in case you blank during the live assessment.

The problem

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 = 4
graph_from = [2,2,1,4]
graph_to = [1,3,4,3]
graph_weight = [100,200,10,20]
source = 1
destination = 3
return = 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)​
The path 1 -> 2 -> 3 has stress max(100, 200) = 200.
The path 1 -> 4 -> 3 has stress max(10, 20) = 20.
The minimum possible stress is 20.
Example 2
graph_nodes = 5
graph_from = [1,2,1,4,1,5]
graph_to = [2,3,4,3,5,3]
graph_weight = [10,5,3,2,4,6]
source = 1
destination = 3
return = 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.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick: you want to minimize the maximum edge on a path, which is a bottleneck path. Three clean approaches work. First, sort edges by weight and union them with union-find until source and destination connect. The weight of the edge that connects them is your answer. Second, binary search on the stress value and run BFS or DFS using only edges at or under that value. Third, a Dijkstra variant where the cost is max(current, edge) instead of a sum. Union-find is the shortest to write. Pitfalls: treating edges as directed, forgetting source equals destination returns 0 before anything else, and returning the wrong value when they never connect (-1). Weight 0 is also legal, so don't use 0 as a sentinel. If you freeze on the live OA, StealthCoder can surface the union-find skeleton so you only have to check the edge cases.

If you see this problem in your OA tomorrow, the play is to recognize the pattern in 30 seconds. StealthCoder buys you that recognition.

If this hits your live OA

You can drill Minimum Stress Path cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as path with minimum effort. If you have time before the OA, drill that.

⏵ The honest play

You've seen the question. Make sure you actually pass Walmart's OA.

Walmart reuses patterns across OAs. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Minimum Stress Path FAQ

What's the trick in Minimum Stress Path?+

It's a minimax path, not a shortest path. Sort edges by weight and add them to a union-find until source and destination share a component. The last edge added is the answer. No Dijkstra sums needed, and it runs in O(E log E).

Are the edges directed in this Walmart problem?+

No. The names graph_from and graph_to suggest direction, but the statement says every edge is undirected. Add both directions in an adjacency list, or just union both endpoints. Treating them as directed is the most common way to fail hidden tests.

What edge cases should I test?+

Source equals destination should return 0 immediately. Disconnected source and destination return -1. Test weight 0 edges, parallel edges between the same pair, and a single node graph. Also check a graph where the cheapest-sum path differs from the min-max path.

Can I use Dijkstra instead of union-find?+

Yes. Replace the sum with max(current stress, edge weight) and keep a min-heap on that value. It works because the cost never decreases along a path. It's a bit more code than union-find but equally correct at O((V+E) log V).

How do I prepare for this in 48 hours?+

Write union-find with path compression once from memory, then solve this problem with it. Next, write the binary search plus BFS version as a backup. Practice on two or three bottleneck-path variants, and make sure you can state the complexity out loud.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Walmart.

OA at Walmart?
Invisible during screen share
Get it