0130. Surrounded Regions
https://leetcode.com/problems/surrounded-regions
Description
Given an m x n matrix board containing 'X' and 'O', capture all regions that are 4-directionally surrounded by 'X'.
A region is captured by flipping all 'O's into 'X's in that surrounded region.
Example 1:

Example 2:
Constraints:
m == board.lengthn == board[i].length1 <= m, n <= 200board[i][j]is'X'or'O'.
ac1: BFS
It's time consuming, but it's at least original by me.
Last updated
Was this helpful?