一 参考
200. 岛屿数量 - 力扣(LeetCode)
二 代码
class Solution
{
public:int numIslands(vector<vector<char>> &grid){int m = grid.size();int n = grid[0].size();int islandNum = 0;for (int i = 0; i < m; i++){for (int j = 0; j < n; j++){if (grid[i][j] == '1'){islandNum++;dfs(grid, i, j);}}}return islandNum;}
private:void dfs(vector<vector<char>> &grid, int r, int c){if