Code RoomMinimax elevation path
HardPrep Room Coding #1310

Minimax elevation path

CodingAlgorithms & data structuresSenior–Staff~35 min

You are given an n x n `grid` of distinct elevations. Starting at the top-left cell (0,0), you want to reach the bottom-right cell (n-1, n-1). You may move up/down/left/right. The cost of a path is the maximum elevation of any cell it visits (including start and end). Return the minimum possible path cost — i.e. the smallest value t such that there's a path where every cell's elevation is <= t.

Implement
min_max_elevation(grid: list[list[int]]) → int
Examples
in[[[0,2],[1,3]]]out3
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

0:00 of about 35 min
InputExpectedGot
[[[0,2],[1,3]]]3not run yetsample