Skip to content
Anshul Saxena edited this page Jun 20, 2020 · 2 revisions

Problem Description

Given a 2D character matrix A of size N x M, containing 'X' and 'O', capture all regions surrounded by 'X'.

A region is captured by flipping all 'O's into 'X's in that surrounded region.


Example

Input 1:

A = [ [X, X, X, X], [X, O, O, X], [X, X, O, X], [X, O, X, X] ]

Example

Output 1:

A = [ [X, X, X, X], [X, X, X, X], [X, X, X, X], [X, O, X, X] ]

Clone this wiki locally