200. Number of Islands
来源:互联网 发布:linux下载整个文件夹 编辑:程序博客网 时间:2024/05/20 19:16
//9msclass Solution {public: void land_change(vector<vector<char>>& grid,int x,int y) { grid[x][y]='w'; if(y+1<grid[0].size()&&grid[x][y+1]=='1') land_change(grid,x,y+1); if(x+1<grid.size()&&grid[x+1][y]=='1') land_change(grid,x+1,y); if(y-1>=0&&grid[x][y-1]=='1') land_change(grid,x,y-1); if(x-1>=0&&grid[x-1][y]=='1') land_change(grid,x-1,y); } int numIslands(vector<vector<char>>& grid) { int num=0; for(int i=0;i<grid.size();i++) { for(int j=0;j<grid[0].size();j++) { if(grid[i][j]=='1') { land_change(grid,i,j); num++; } } } return num; }};
0 0
- 200. Number of Islands
- 200. Number of Islands
- 200. Number of Islands
- 200. Number of Islands
- 200. Number of Islands
- 200. Number of Islands
- 200. Number of Islands
- 200. Number of Islands
- 200. Number of Islands
- 200. Number of Islands
- 200. Number of Islands
- 200. Number of Islands
- 200. Number of Islands
- 200. Number of Islands
- 200. Number of Islands
- 200. Number of Islands
- 200. Number of Islands
- 200. Number of Islands
- H5动效的常见制作手法
- centos6.5下如何修改MySQL默认用户root的密码
- 科学健身,锻炼身体,增长肌肉
- java char String中涉及到的length字符长度概念的研究
- 51nod Huffman算法
- 200. Number of Islands
- MAC下myeclipse 的Console乱码解决
- 【杭电oj】3789 - 奥运排序问题(排名,坑题)
- c语言:定长顺序串的基本操作实实现
- UVA 11082 Matrix Decompressing(网络流)
- 【笔试/面试】MFC(五)
- 李煜-问君能有几多愁
- SGU 149 Computer Network(树形DP)
- org.springframework.beans.factory.BeanCreationException