Medium
Quiz
#130 Surrounded Regions
APPROACH
You are given an m x n matrix board of 'X' and 'O' characters. Capture all surrounded regions:
- Connect: Cells are adjacent if they share a horizontal or vertical edge.
- Region: A region is a group of connected 'O' cells.
- Surround: A region is surrounded when none of its 'O' cells touch the board's border.
Replace every 'O' in a surrounded region with 'X' in-place. Do not return anything.
1 of 4
1:00
What is the optimal approach for this problem?