FreeCareerPath
Build the PrimitiveMedium

Surrounded Regions

Write `solve(board)` flipping every `"O"` region fully surrounded by `"X"` into `"X"`, modifying the board in place. A region touching the border is not surrounded. [["X","X","X"],["X","O","X"],["X","X","X"]] -> the O becomes X Checking whether a region is enclosed is awkward. Invert the problem: flood from every `"O"` on the border, mark everything reachable as safe, then flip whatever is left. The rule becomes a single reachability question.

What to expect: A timer starts when you begin. Edit the starter code, run it against the test suite as many times as you like, then finish when you're done. The reference solution and interviewer follow-up questions unlock only after you finish.

Log in to start this session

Timed sessions and your results for "Surrounded Regions" are saved to your account — logging in takes a few seconds.

Surrounded Regions — FreeCareerPath