#K85287. Minimum Effort Path
Minimum Effort Path
Minimum Effort Path
In this problem, you are given a grid of integers where each integer represents the height of that cell. Your task is to find a path from the top-left corner to the bottom-right corner minimizing the effort. The "effort" of a path is defined as the maximum absolute difference in heights between any two consecutive cells along the path. Formally, if a path consists of adjacent cells, the effort is $$\max_{(u,v) \in path} \left| h(u) - h(v) \right|$$ where (h(u)) is the height of cell (u).
You can move in four directions: up, down, left, and right. The input grid dimensions and the grid values are provided as standard input. Your program should output the minimum effort required to travel from the top-left to the bottom-right corner.
Be sure to read input from standard input and write the result to standard output.
inputFormat
The first line contains two integers (m) and (n) representing the number of rows and columns in the grid. The next (m) lines each contain (n) space-separated integers representing the heights of the grid cells.
outputFormat
Output a single integer, the minimum effort required to travel from the top-left cell to the bottom-right cell.## sample
3 3
1 2 2
3 8 2
5 3 5
2