Red Hat interview question

Pacific-Atlantic water flow problem [leetcode]