u*l 发帖数: 1943 | 1 http://discuss.leetcode.com/questions/1223/surrounded-regions
First scan the four edges of the board, if you meet an 'O', call a
recursive mark function to mark that region to something else (for example,
'+');
scan all the board, if you meet an 'O', flip it to 'X';
scan again the board, if you meet an '+', flip it to 'O';
如果是
XXX
OOX
XXX
第二个O没有被X环绕,解法里面却变为X。 | r*********n 发帖数: 4553 | 2 不是说了是recursive mark function,意思就是从第一个O一直dfs下去找所有
connected Os |
|