778. Swim In Rising Water
Practice Swim In Rising Water for free on NudgeCode: Hard, Graph pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.
grid is an n x n board where grid[r][c] is the ground height of that cell. It starts raining, and at time t the water level everywhere is t. You can move between two cells that are up, down, left or right of each other when both heights are at most t; moving takes no time. Start at the top-left cell and return the smallest time t at which you can reach the bottom-right cell.
Example
grid = [[0,2],
[1,3]] -> 3
Constraints
- 1 <= n <= 50
- The heights are a permutation of
0 .. n*n - 1