Understand the problem
Restate the problem precisely. Interviewers reward candidates who pause, define the contract, and name the guarantees before coding.
There is an `m × n` rectangular island that borders both the Pacific Ocean and Atlantic Ocean. The Pacific Ocean touches the island's left and top edges, and the Atlantic Ocean touches the island's right and bottom edges. Given an `m × n` integer matrix `heights` where `heights[r][c]` represents the height above sea level of the cell at coordinate `(r, c)`. Water can flow from a cell to a neighboring (4-connected) cell only if the neighbor's height is **less than or equal** to the current cell's height. Return a list of grid coordinates `[r, c]` from which rain water can flow to both the Pacific and Atlantic oceans.
Once you've drafted a response, click Submit for AI review and a senior engineer will critique your reasoning.