Home
Log in
DescriptionSubmissionsSolution
DescriptionSubmissionsSolution
Loading...

Log in to run or submit

grid =

Codey

Practise coding problems, test your solutions and track your progress.

Explore

  • Problems
  • About
  • Contact

Legal

  • Privacy Policy
  • Terms of Use

© 2026 Codey. Personal learning project.

Solution
Updated: 2026-02-23

Idea

Minimize the maximum elevation you must tolerate along a path.

Approach

Dijkstra on states (r,c) where path cost is max(elevation on path). Relax neighbor with newCost = max(currentCost, grid[nr][nc]).

Why it works

This is a shortest-path problem under the minimax metric; Dijkstra applies because relaxation is monotone.

Code
Loading...
Complexity
Time: O(n^2 log n)
Space: O(n^2)
Solution
Updated: 2026-02-23

Idea

Minimize the maximum elevation you must tolerate along a path.

Approach

Dijkstra on states (r,c) where path cost is max(elevation on path). Relax neighbor with newCost = max(currentCost, grid[nr][nc]).

Why it works

This is a shortest-path problem under the minimax metric; Dijkstra applies because relaxation is monotone.

Code
Loading...
Complexity
Time: O(n^2 log n)
Space: O(n^2)