Problem 417 · Medium
Multi-source BFS from both borders; cells reachable from both are result.
Open the interactive visualisation