Practice Problem

Pacific Atlantic Water Flow

Difficulty: Medium

Given a matrix of heights, find all cells from which water can flow to both the Pacific and Atlantic oceans.