Can you please give me a code that runs properly this time Given a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'. A region is captured by flipping all 'O's into 'X's in that surrounded region. For example, for the following board, X X X X X O O X X X O X X O X X After capturing all regions, the board becomes X X X X X X X X X X X X
Can you please give me a code that runs properly this time
Given a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'.
A region is captured by flipping all 'O's into 'X's in that surrounded region.
For example, for the following board,
X X X X
X O O X
X X O X
X O X X
After capturing all regions, the board becomes
X X X X
X X X X
X X X X
X O X X
The
Sample input.txt
6
X X X X X O
X O X O O X
X X O O O X
X X X O X X
X O X X O O
X X X X X X
The first line is a number indicating the size of the board; in the above example, 6 means the board is .
Output for in console:
X X X X X O
X X X X X X
X X X X X X
X X X X X X
X X X X O O
X X X X X X
Step by step
Solved in 4 steps with 2 images