Problem Description
Given a 2D character matrix A of size N x M
, 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.
1 <= N, M <= 103
First and only argument 2D character matrix A of size N X M
.
Make changes to the the input only as matrix is passed by reference.
Input 1:
A = [ [X, X, X, X], [X, O, O, X], [X, X, O, X], [X, O, X, X] ]
Output 1:
A = [ [X, X, X, X], [X, X, X, X], [X, X, X, X], [X, O, X, X] ]
Explanation 1:
'O' in (4,2) is not surrounded by X from below.
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a question? Checkout Sample Codes for more details.