Dashboard
LC #778

Swim in Rising Water

Pattern · ?GoogleAmazon

Problem

Find the minimum time to swim from top-left to bottom-right of a grid, where you can only move to cells with value ≤ current time.

Constraints

  • n == grid.length == grid[i].length
  • 1 ≤ n ≤ 50
  • 0 ≤ grid[i][j] < n²
  • All values unique

Example

Input
grid = [[0,2],[1,3]]
Output
3
Why
At time 3, path 0→2→3 or 0→1→3 is possible (all cells ≤ 3)

Spot the pattern

Which pattern cracks it?

Hints

One at a time
Solve on LeetCode ↗