Easy Python O(n^2) solution using DFS
IntuitionNeed to have all the areas pre-computed and then try to turn every 0 into a 1 and see what all islands it can touch to add their areas.ApproachPre-comp
# Intuition
Need to have all the areas pre-computed and then try to turn every 0 into a 1 and see what all islands it can touch to add their areas.

# Approach

Pre-compute all the areas of all islands and change the values to some proxy greater than 1 so that we dount double count any point. Once that is done and saved in a hashmap, we go through all thr 0s and see what all islands it is touching in order to add the areas of them to the 1 of the flip itself.

Make sure that we dont reuse the same island to double count its area as a single flip can be touch the same island in 2 different point hence we use the used set.

# Code
```python3 []
class Solution:
    def largestIsland(self, grid: List[List[int]]) -> int:
        islandAreas = {}
        proxy=2

        def findArea(i,j, proxy):
            if i<0 or i>=len(grid) or j<0 or j>=len(grid) or grid[i][j]!=1:
                return 0
            grid[i][j]=proxy
            return 1 + findArea(i+1,j,proxy)+findArea(i,j+1,proxy)+findArea(i-1,j,proxy)+findArea(i,j-1,proxy)
        
        def findNewArea(i,j):
            used = set()
            ret = 1
            if i+1<len(grid) and grid[i+1][j]!=0 and grid[i+1][j] not in used:
                ret+=islandAreas[grid[i+1][j]]
                used.add(grid[i+1][j])
            if i-1>=0 and grid[i-1][j]!=0 and  grid[i-1][j] not in used:
                ret+=islandAreas[grid[i-1][j]]
                used.add(grid[i-1][j])
            if j+1<len(grid) and grid[i][j+1]!=0 and grid[i][j+1] not in used :
                ret+=islandAreas[grid[i][j+1]]
                used.add(grid[i][j+1])
            if j-1>=0 and grid[i][j-1]!=0 and grid[i][j-1] not in used :
                ret+=islandAreas[grid[i][j-1]]
                used.add(grid[i][j-1])
            return ret

        for i in range(len(grid)):
            for j in range(len(grid)):
                if grid[i][j]==1:
                    area = findArea(i,j,proxy)
                    islandAreas[proxy]=area
                    proxy+=1
        if not islandAreas:
            return 1
        ret_max = max(islandAreas.values())

        for i in range(len(grid)):
            for j in range(len(grid)):
                if grid[i][j]==0:
                    ret_max = max(ret_max,findNewArea(i,j))
        return ret_max
                    
        

        
```
['Python3']