Faster then 96% | Easy to understand
The main problem is find every island and island size.\nAfter that we can get private identifer to every island in a map and size;\nAfter that we must check onl
The main problem is find every island and island size.\nAfter that we can get private identifer to every island in a map and size;\nAfter that we must check only 4 cells near every "0"  and find bugets sum of islands near that point.\nO(n^2) for find every island;\nO(n^2) for marking every island;\nO(n^2) for find bigest island in total.\n\nTotal time complexity is O(n^2).\n\n```\nclass Solution {\n    int count = 0;\n    int num = 10;\n    public int largestIsland(int[][] grid) {\n        Map<Integer, Integer> map = new HashMap();\n        for (int i = 0; i < grid.length; i++) {\n            for (int j = 0; j < grid.length; j++) {\n                if (grid[i][j] == 1) {\n                    count = 0;\n                    find(grid, i, j);\n                    map.put(num, count);\n                    change(grid, i, j);\n                    num++;\n                }\n            }\n        }\n        int max = 0;\n        for (int i = 0; i < grid.length; i++) {\n            for (int j = 0; j < grid.length; j++) {\n                if (grid[i][j] == 0) {\n                    count = 1;\n                    int[] tmp = new int[4];\n                    if(i > 0) tmp[0]=grid[i-1][j];\n                    if(i+1 < grid.length) tmp[1]=grid[i+1][j];\n                    if(j > 0) tmp[2]=grid[i][j-1];\n                    if(j+1 < grid[0].length) tmp[3]=grid[i][j+1];\n                    for (int f = 0; f < 3; f++) {\n                        for (int g = f+1; g < 4; g++) {\n                            if (tmp[f] == tmp[g]) tmp[f] = 0;\n                        }\n                    }\n                    for (int x: tmp) {\n                        if (x > 9) count += map.get(x);\n                    }\n                    \n                    max = Math.max(max, count);\n                }\n            }\n        }\n        if (max == 0) return map.get(10);\n        return max;\n    }\n    \n    public void find(int[][] grid, int i, int j) {\n        count++;\n        grid[i][j] = 2;\n        if(i > 0 && grid[i-1][j] == 1) find(grid, i-1, j);\n        if(i+1 < grid.length && grid[i+1][j] == 1) find(grid, i+1, j);\n        if(j > 0 && grid[i][j-1] == 1) find(grid, i, j-1);\n        if(j+1 < grid[0].length && grid[i][j+1] == 1) find(grid, i, j+1);\n    }\n    \n    public void change(int[][] grid, int i, int j) {\n        grid[i][j] = num;\n        if(i > 0 && grid[i-1][j] == 2) change(grid, i-1, j);\n        if(i+1 < grid.length && grid[i+1][j] == 2) change(grid, i+1, j);\n        if(j > 0 && grid[i][j-1] == 2) change(grid, i, j-1);\n        if(j+1 < grid[0].length && grid[i][j+1] == 2) change(grid, i, j+1);\n    }\n}\n```
['Java']