LearnPy Hub
← Arena
AdvancedRating 1700

Path With Least Effort

The effort of a route is the largest height difference between two neighbouring cells on it. Print the least effort to go from the top-left to the bottom-right cell (moving up, down, left, right).

Input

r and c, then r rows of heights.

Output

One integer.

Sample 1

Input
3 3
1 2 2
3 8 2
5 3 5
Output
2

Sample 2

Input
3 3
1 2 3
3 8 4
5 3 5
Output
1
solution.py
Output appears here
Path With Least Effort · Python Arena problem · LearnPy Hub