[LeetCode] Surrounded Regions, Solution

http://fisherlei.blogspot.com/search?q=Surrounded+Region

 

特别说一下,里面实现bfs的code挺有意思的

 

 

[LeetCode] Surrounded Regions, Solution
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:          }  
[LeetCode] Surrounded Regions, Solution

[LeetCode] Surrounded Regions, Solution

上一篇:LeetCode: Rotate Image


下一篇:通用用户权限管理系统组件4.0 版本 - 导入导出Microsoft Excel 2010的例子