Exercises/#44 Pacific Atlantic Water Flow
#44

Pacific Atlantic Water Flow

MediumπŸ•ΈοΈ Graphs
90 XP

Problem

Given an mΓ—n matrix of heights, find all cells where water can flow to both the Pacific and Atlantic oceans.

Examples

Input: heights=[[1,2,2,3,5],[3,2,3,4,4],[2,4,5,3,1],[6,7,1,4,5],[5,1,1,2,4]]
Output: [[0,4],[1,3],[1,4],[2,2],[3,0],[3,1],[4,0]]
graphbfsdfsmatrix
AI Assistantβ€” powered by AI

Unlock hints progressively β€” start gentle, go deeper only if needed.

πŸ’‘

Level 1: Gentle Nudge

A subtle direction

πŸ—ΊοΈ

Level 2: Approach

The algorithm to use

πŸ”

Level 3: Detailed

Step-by-step guidance

44 / 150

Your Solution

⚑ JavaScript

to save progress and use AI features