Capture Surrounded Regions
In a grid of "X" and "O", capture every region of "O" that is not connected to the border by flipping it to "X". Return the resulting grid.
Examples
EXAMPLE WALKTHROUGHclassic
A guided view of the published example, not a trace of your code.
INPUT
[[["X","X","X","X"],["X","O","O","X"],["X","X","O","X"],["X","O","X","X"]]]TASKcapture_surrounded()
EXPECTED OUTPUT
[["X","X","X","X"],["X","X","X","X"],["X","X","X","X"],["X","O","X","X"]]Start with the input values shown in this example.
Example 1 of 3
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: classic
Input: board = [["X"]]
Output: [["X"]]
Explanation: single
Input: board = [["O","O"],["O","O"]]
Output: [["O","O"],["O","O"]]
Explanation: all on the border
Hint 1
Mark every O reachable from the border first; flip everything else.