Code Room
CodingHardcod-g745
Subject Shortest pathLevel Senior–Staff~35 minCommon in Algorithms & data structures interviewsIndustries Software development, Technology

Question

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.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.