You are a hiker preparing for an upcoming hike. You are given heights, a 2D array of size rows x columns, where heights[row][col] represents the height of cell (row, col). You are situated in the top-left cell, (0, 0), and you hope to travel to the bottom-right cell, (rows-1, columns-1). The effort required to travel from one cell to an adjacent cell is the absolute difference of their heights. Return the minimum effort required to travel from the top-left cell to the bottom-right cell.
Java
Path With Minimum Effort
You are a hiker preparing for an upcoming hike. You are given heights, a 2D array of size rows x columns, where heights[row][col] represents the height of cell (row, col). You are situated in the top-left cell, (0, 0), and you hope to travel to the bottom-right cell, (rows-1, columns-1). The effort required to travel from one cell to an adjacent cell is the absolute difference of their heights. Return the minimum effort required to travel from the top-left cell to the bottom-right cell.
Example 1:
Input: [[1,2,2],[3,8,2],[5,3,5]]
Output: 2
Input
arr =[[1,2,2],[3,8,2],[5,3,5]]
Initialize: Start at (0,0) with effort 0. Use Dijkstra to find min-effort path.