1631. Path with Minimum Effort

Practice Path with Minimum Effort for free on NudgeCode: Medium, Graph pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.

heights[r][c] is the height of cell (r, c). You start at the top-left cell and want to reach the bottom-right cell, moving up, down, left or right. The effort of a route is the largest absolute height difference between two consecutive cells on it. Return the minimum effort over all routes.

Example

heights = [[1,2,2],
           [3,8,2],
           [5,3,5]]  ->  2

(The route 1 -> 3 -> 5 -> 3 -> 5 never climbs or drops more than 2.)

Constraints