Problem 417 · Medium

Pacific Atlantic Water Flow

Multi-source BFS from both borders; cells reachable from both are result.

Open the interactive visualisation