最基础的DFS了。 lass Solution { public: void dfs(vector<vector<char> >& grid, int i, int j, int w, int h) { grid[i][j] = '0'; if(grid[i - 1][j] == '1' && i - 1 >= 0) dfs(grid, i - 1, j, w, h); if(grid[i + 1][j] == '1' && i + 1 < w) dfs(...