




Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Consider the grid as a graph, where adjacent cells have an edge with cost of the difference between the cells.
If you are given threshold k, check if it is possible to go from (0, 0) to (n-1, m-1) using only edges of ≤ k cost.
Binary search the k value.