O44
Surrounded Regions
Problem Statement & Objective
Given an m x n matrix board containing 'X' and 'O', capture all regions that are 4-directionally surrounded by 'X'.
Function Signature (Python)
surrounded_regions(board: list[list[str]]) -> list[list[str]]Input & Output Contract
Output Rule:Güncellenmiş tahta matrisi.
System Constraints
m == tahta.length, n == tahta[i].length
1 <= m, n <= 200
tahta[i][j] ∈ {'X', 'O'}Example Execution Walkthrough
tahta = [
['X','X','X','X'],
['X','O','O','X'],
['X','X','O','X'],
['X','O','X','X']
]
Sınırdaki O hariç içtekiler X olur.Example Test Scenarios (3)
Example 1
Input:
[[["X","X","X","X"],["X","O","O","X"],["X","X","O","X"],["X","O","X","X"]]]Expected Output:
[["X","X","X","X"],["X","X","X","X"],["X","X","X","X"],["X","O","X","X"]]Example 2: Tek X
Input:
[[["X"]]]Expected Output:
[["X"]]Example 3: Tamamı Sınırda
Input:
[[["O","O"],["O","O"]]]Expected Output:
[["O","O"],["O","O"]]