The Path With Minimum Effort problem asks you to find a path from the top-left to the bottom-right of a grid minimizing the maximum absolute difference between consecutive cells along the path. This is the classic bottleneck path problem on a grid. The array, matrix, union find, BFS, DFS, binary search, and heap interview pattern is fully exercised.
Cohesity, Microsoft, Meta, Amazon, TikTok, Google, and Bloomberg ask this because it's the "minimize the maximum" grid path problem — the dual of maximizing the minimum. Multiple efficient solutions exist (Dijkstra, binary search + BFS, Union-Find), demonstrating algorithmic versatility.
Modified Dijkstra (min bottleneck). effort[i][j] = minimum possible maximum effort to reach (i,j). Use a min-heap of (effort, row, col). Initialize effort[0][0]=0. For each cell: compute new_effort = max(current_effort, |grid[nr][nc] - grid[r][c]|). If new_effort < effort[nr][nc], update and push. Return effort[m-1][n-1].
Grid:
1 2 2
3 8 2
5 3 5
Path (0,0)→(0,1)→(0,2)→(1,2)→(2,2): efforts [1,0,6,3]. Max=6. Path through (1,1): higher effort. Optimal path: 1→2→3→2→5? effort = max(1,2,3)=3? Let me check: 1→3→5→3→5: max(2,2,2,2)=2. Actually optimal = 2 via the bottom path (efforts: |1-3|=2,|3-5|=2,|5-3|=2,|3-5|=2).
Path With Minimum Effort and Path With Maximum Minimum Value are duals of each other. Both use modified Dijkstra — just with different objective (min-max vs max-min). Binary search + BFS is an alternative: binary search on the effort value, BFS to check if a valid path exists within that effort. Practice both approaches and understand their complexity trade-offs (Dijkstra: O(mn log mn), Binary search + BFS: O(mn log(max_diff))).
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Path With Maximum Minimum Value | Medium | Solve | |
| Swim in Rising Water | Hard | Solve | |
| Find the Safest Path in a Grid | Medium | Solve | |
| Last Day Where You Can Still Cross | Hard | Solve | |
| Number of Closed Islands | Medium | Solve |