You are given an m x n matrix board containing letters 'X' and 'O'. Capture regions that are surrounded: Connect every 'O' cell with adjacent cells horizontally or vertically to form regions. A region is surrounded by 'X' cells if you can connect the region with 'X' cells and none of the region cells are on the edge of the board. A surrounded region is captured by replacing all 'O's in it with 'X's.
Click Run to execute sample tests.