Approach Summary
Reverse DFS from ocean borders inward. Cells reachable from both oceans are the answer.
How to Recognize This Pattern
- Flow from borders inward (reverse thinking)
- Two visited sets
Complexity Analysis
Time Complexity
O(m × n)
Space Complexity
O(m × n)
Tags
Graph DFS BFS Matrix