heights[r][c] is the height of a cell. You walk from the top-left to the bottom-right cell, moving up, down, left or right. The effort of a path is the largest absolute difference in height between two neighbouring cells on the path. Return the smallest effort over all paths.
For [[1, 2, 2], [3, 8, 2], [5, 3, 5]] the answer is 2.
Example 1
Input:
minimum_effort_path([[1, 2, 2], [3, 8, 2], [5, 3, 5]])
Output:
2
Example 2
Input:
minimum_effort_path([[1, 2, 3], [3, 8, 4], [5, 3, 5]])
Output:
1
1 <= rows, cols <= 1001 <= heights[r][c] <= 10**6No results yet
Run your code to check it against the examples, or submit to run every test.