130. Surrounded Regions
Practice Surrounded Regions for free on NudgeCode: Medium, Graph pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.
The board is a grid of "X" and "O". A group of "O" cells connected up, down, left or right is captured when none of its cells lies on the border of the board. Replace every captured "O" with "X", in place, and return nothing. Groups that touch the border stay as they are.
Example
board = [["X","X","X","X"],
["X","O","O","X"],
["X","X","O","X"],
["X","O","X","X"]]
-> [["X","X","X","X"],
["X","X","X","X"],
["X","X","X","X"],
["X","O","X","X"]]
Constraints
- 1 <= m, n <= 200 (m rows, n columns)
- board[i][j] is
"X"or"O"