[c++] beat 90% runtime & space usage, easy to understand solution
First Round - find all islands, get sizes and marked with different colors (labeling and also avoid duplicated searches).\nSecond Round - traverse all \'0\'s, f
First Round - find all islands, get sizes and marked with different colors (labeling and also avoid duplicated searches).\nSecond Round - traverse all \'0\'s, find all adjacented islands to make a bigger one. Search the sizes in cache to get the size of the new island.\n\n```\nclass Solution {\npublic:\n    int largestIsland(vector<vector<int>>& grid) {\n        int color = 2;\n        unordered_map<int, int> sizes;\n        for (int i = 0; i < grid.size(); i++)\n            for (int j = 0; j < grid[0].size(); j++)\n                if (grid[i][j] == 1)\n                {\n                    int count = 0;\n                    colorize(grid, i, j, color, count);\n                    sizes[color] = count;\n                    color++;\n                }\n        \n        int res = 1; \n        for (auto kv:sizes)\n            res = max(res, kv.second);\n        \n        for (int i = 0; i < grid.size(); i++)\n            for (int j = 0; j < grid[0].size(); j++)\n                if (grid[i][j] == 0)\n                    res = max(res, change(grid, sizes, i, j));\n        \n        return res;\n    }\n    \n    void colorize(vector<vector<int>>& grid, int i, int j, int color, int& count) {\n        count++;\n        grid[i][j] = color;\n        if (i-1 >=0 && grid[i-1][j] == 1) colorize(grid, i-1, j, color, count);\n        if (i+1 < grid.size() && grid[i+1][j] == 1) colorize(grid, i+1, j, color, count);\n        if (j-1 >=0 && grid[i][j-1] == 1) colorize(grid, i, j-1, color, count);\n        if (j+1 < grid[0].size() && grid[i][j+1] == 1) colorize(grid, i, j+1, color, count);\n    }\n    \n    int change(vector<vector<int>>& grid, unordered_map<int, int>& sizes, int i, int j)\n    {\n        set<int> neighbors;\n        if (i-1 >=0 && grid[i-1][j] > 1) neighbors.insert(grid[i-1][j]);\n        if (i+1 < grid.size() && grid[i+1][j] > 1) neighbors.insert(grid[i+1][j]);\n        if (j-1 >=0 && grid[i][j-1] > 1) neighbors.insert(grid[i][j-1]);\n        if (j+1 < grid[0].size() && grid[i][j+1] > 1) neighbors.insert(grid[i][j+1]);\n                                                                \n        int res = 1;\n        for (int c:neighbors)\n            res += sizes[c];\n        \n        return res;\n    }\n};\n```
['Depth-First Search', 'C', 'C++']