You are given a 2-D grid board with letters 'X' and 'O'.
• Cells connect up, down, left, and right.
• A region is a group of connected 'O' cells.
• If an 'O' region is fully surrounded by 'X' (and no 'O' from that region
touches the outer edge of the grid),
change all 'O' in that region to 'X'.
Do the changes in the same board (no need to return a new grid).
Input: board = [ ["X","X","X","X"], ["X","O","O","X"], ["X","X","O","X"], ["X","O","X","X"] ]
Output: [ ["X","X","X","X"], ["X","X","X","X"], ["X","X","X","X"], ["X","O","X","X"] ]
Explanation:
The center 'O' cells are completely surrounded and become 'X'. The single 'O' in the bottom row touches the border, so it stays.
Input: board = [ ["O","O","X"], ["O","X","O"], ["X","O","X"] ]
Output: [ ["O","O","X"], ["O","X","O"], ["X","O","X"] ]
Explanation:
No region of 'O' is fully surrounded (all are connected to the border).
Accepted:
Submission: