Code RoomMinimum effort path
HardPrep Room Coding #4508

Minimum effort path

CodingAlgorithms & data structuresSenior–Staff~40 min

You are given an m x n grid of non-negative integer heights. Starting at (0,0) and ending at (m-1,n-1), moving 4-directionally, the 'effort' of a path is the maximum absolute height difference between any two consecutive cells on that path. Return the minimum possible effort over all paths. The grid has at least one cell.

Implement
min_effort_path(heights: list[list[int]]) → int
Examples
in[[[1,2,2],[3,8,2],[5,3,5]]]out2
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 40 min
InputExpectedGot
[[[1,2,2],[3,8,2],[5,3,5]]]2not run yetsample