The Runtime Theory
hardLeetCode#minimax-path#heap

Swim in Rising Water

Find the minimum water level at which a path exists from the top-left to bottom-right of a grid.

The Runtime Theory Team25 min read
Solve it

Solving happens on the judge — come back and mark it done

Sample cases

ingrid=[[0,2],[1,3]]

out3

ingrid=[[0,1,2,3,4],[24,23,22,21,5],[12,13,14,15,16],[11,17,18,19,20],[10,9,8,7,6]]

out16

ingrid=[[1]]

out1

Find the minimum water level at which a path exists from the top-left to bottom-right of a grid.

A good solution should

  • State the invariant or decision rule that makes the approach correct.
  • Explain time and space costs in terms of input size and required output.
  • Handle empty, minimal, duplicate, and boundary-shaped inputs.

Reasoning prompt

The path cost is its maximum cell elevation, not the sum. Compare a min-heap traversal with binary search plus reachability.

Use the linked judge for the canonical challenge. The examples above are compact TRT checks; create additional tests around the boundary most likely to break your invariant.

More practice in this topic

One dispatch a week

The trace behind each problem, the tradeoff that explains it, and one technical dispatch per week — no noise.

One technical dispatch per week. No noise.

Not started

Sign in to save your learning progress.

Sign in to save