Tap here to switch tabs
Problem
Submissions

Problem: Surrounded Regions

Try to solve the Surrounded Regions problem.

Statement

You are given an m×nm \times n grid board consisting of characters 'X' and 'O'.

Capture all regions that are surrounded by 'X'.

A region is considered captured when every 'O' within it is replaced by 'X'. A region of 'O' cells is surrounded if it is completely enclosed by 'X' cells horizontally and vertically, such that no cell in the region connects to any boundary of board through horizontally or vertically adjacent 'O' cells.

Modify board in place.

Constraints:

  • m ==== board.length

  • n ==== board[i].length

  • 1≤1 \leq m, n ≤200\leq 200

  • board[i][j] is 'X' or 'O'.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Surrounded Regions

Try to solve the Surrounded Regions problem.

Statement

You are given an m×nm \times n grid board consisting of characters 'X' and 'O'.

Capture all regions that are surrounded by 'X'.

A region is considered captured when every 'O' within it is replaced by 'X'. A region of 'O' cells is surrounded if it is completely enclosed by 'X' cells horizontally and vertically, such that no cell in the region connects to any boundary of board through horizontally or vertically adjacent 'O' cells.

Modify board in place.

Constraints:

  • m ==== board.length

  • n ==== board[i].length

  • 1≤1 \leq m, n ≤200\leq 200

  • board[i][j] is 'X' or 'O'.