1. Surrounded regions shouldn’t be on the border, which means that any 'O' on the border of the matrix is not flipped to 'X'.
2. Any ‘O’ or group of connected ‘O’ are said to be surrounded by ‘X’ when all cells touching the boundary of the group of ‘O’ must contain ‘X’.
The first line of the input contains an integer ‘T’ denoting the number of test cases.
The next 2 * T lines describe the ‘T’ test cases.
The first line of each test case contains two space-separated positive integers ‘N’ and ‘M’ denoting the number of the rows and columns in a matrix respectively.
In the next ‘N’ lines of each test case, the ith line contains a string of length ‘M’ containing either ‘X’ or ‘O’.
For each test case, print N lines each line containing M characters denoting the matrix element at position MATRIX[i][j] where i and j are the indices of the 2 - D array.
The output of each test case will begin from a new line.
You do not need to print anything, it has already been taken care of. Just implement the given function.
1 <= T <= 50
1 <= N <= 10 ^ 4
1 <= M <= 10 ^ 4
1 <= N * M <= 10 ^ 4
Where ‘T’ is the number of test cases, ‘N’ is the number of rows, ‘M’ is the number of columns.
Time Limit: 1 sec
Capturing Grid
Rotting Oranges
Distance to a Cycle in Undirected Graph
Search In A Sorted 2D Matrix
Spiral Matrix
Spiral Matrix
Spiral Matrix