Optimal Algorithmic Approach
Two BFS/DFS passes from each ocean boundary; intersect reachable sets.
Core Invariants & Edge Cases
- Reverse-flow BFS/DFS from ocean boundaries inward
- Pacific: top row + left col; Atlantic: bottom row + right col
- Cells reachable from both = answer