Skip to main content
Pacific Atlantic Water Flow | AlgoCracked
AlgoCracked
ProblemsPacific Atlantic Water Flow
Medium52.0% acceptance
Blind75ArrayDfsBfsMatrix

Pacific Atlantic Water Flow

An m × n grid heights gives the elevation of each cell. The Pacific ocean touches the top and left edges of the grid; the Atlantic touches the bottom and right edges. Water on a cell can flow to a neighbour (up, down, left, or right) whose height is equal or lower , and water reaching an edge drains into the adjacent ocean. Return every cell [r, c] from which water can flow to both oceans. The cells may be returned in any order . Input format Input is [heights] , e.g. [[[1,2],[4,3]]] .

Loading workspace…