My Blog List

[Leetcode Solution] Surrounded Regions

Analysis

  • If a 'o' grid region is completely surrounded by 'x' then it will be replaced as 'x'
  • Traversal the non-surrounded 'o' region by dfs from 'o' grid lying at the edge of the board
  • Label all the 'o' grid which is not being surrounded
  • Replace all the 'o' grid which is not labeled

Code


No comments:

Post a Comment

Enter you comment