hardAdvanced GraphsGoogle
Rising Tide Pathfinder
A swimmer in a bowl-shaped grid can enter cell (r,c) only when the tide ≥ its elevation. Find the earliest tide reaching bottom-right.
Given an n×n elevation grid, return the minimum tide time t such that there exists a path from (0,0) to (n-1,n-1) using cells with elevation ≤ t.
Choose approach
0
cur
2
1
3
1/5
Narrationstep 1 of 5
Settle (0,0) at tide 0.
Variables
r=0
c=0
tide=0
How to think about it
- Each cell has a 'cost' = elevation; path cost = max cell along path.
- Classic Dijkstra generalization: relax = max.
- Early exit when the goal pops.
Edge cases to catch in interview
- 1×1 grid -> grid[0][0].
- Monotonic staircase -> last cell's value.
Examples
Example 1
3{"grid":[[0,2],[1,3]]}
Try your own input
SpacePlay / pause
← / →Previous / next step
RReset to start
. or >Cycle speed