 All Problems
Path With Minimum Effort
medium
union-find
binary search
heap
graph
google
amazon

You are given an m x n matrix of heights. A route's effort is the maximum absolute difference in heights between two consecutive cells along the route.

Return the minimum effort required to travel from the top-left to the bottom-right cell.

Example 1:

Input: heights = [[1,2,2],[3,8,2],[5,3,5]]
Output: 2

Example 2:

Input: heights = [[1,2,3],[3,8,4],[5,3,5]]
Output: 1

Constraints:

  • m == heights.length
  • n == heights[i].length
  • 1 <= m, n <= 100
Run to check your code against the sample cases, or submit to run every case