http://fisherlei.blogspot.com/search?q=Surrounded+Region
特别说一下,里面实现bfs的code挺有意思的
int k =0; 20: while(k<xIndex.size()) 21: { 22: int x = xIndex[k]; 23: int y = yIndex[k]; 24: visited[x*row +y] =1; 25: if(IsInBoundary(x, y, row, col)) surranded = false; 26: if(x<row-1 && board[x+1][y] == ‘O‘ && !IsVisited((x+1)*row+y)) {xIndex.push_back(x+1); yIndex.push_back(y);} 27: if(y<col-1 && board[x][y+1] == ‘O‘ && !IsVisited(x*row+y+1)) {xIndex.push_back(x); yIndex.push_back(y+1);} 28: k++; 29: }