45. Path With Minimum Effort Code
Medium

Problem Statement

Given a grid of heights, return the minimum effort required to travel from the top-left cell to the bottom-right cell. The effort of a path is the maximum absolute difference between consecutive cells on that path.

Examples

1Example 1
Input:
{ "heights": [ [ 1, 2, 2 ], [ 3, 8, 2 ], [ 5, 3, 5 ] ] }
Output:
2
2Example 2
Input:
{ "heights": [ [ 1, 2, 3 ], [ 3, 8, 4 ], [ 5, 3, 5 ] ] }
Output:
1
3Example 3
Input:
{ "heights": [ [ 1, 2, 1, 1, 1 ], [ 1, 2, 1, 2, 1 ], [ 1, 2, 1, 2, 1 ], [ 1, 2, 1, 2, 1 ], [ 1, 1, 1, 2, 1 ] ] }
Output:
0
Loading...

Sign in to Run Code and Submit