X = player1, Y = player2.
Given a 2D matrix and a position, return whether one of the players is surrounded by the other player.
This problem asks you to model“surrounded”as a grid connectivity question. From a given position, you typically explore the region with DFS or BFS, checking whether the player’s area can reach the boundary or escape through adjacent cells. If it cannot, the player is considered surrounded. The key ideas are four-directional traversal, visited-state tracking, and careful handling of boundary conditions.