java no brain approach
```\nclass Solution {\n    class Info{\n        int wallsToBuild;\n        Set threatenArea;\n        Set origArea;\n        public Info(int x, Set threatenArea
```\nclass Solution {\n    class Info{\n        int wallsToBuild;\n        Set<Integer> threatenArea;\n        Set<Integer> origArea;\n        public Info(int x, Set<Integer> threatenArea, Set<Integer> origArea){\n            this.wallsToBuild = x;\n            this.threatenArea = threatenArea;\n            this.origArea = origArea;\n        }\n    }\n    int res = 0;\n    public int containVirus(int[][] grid) {\n        int rows = grid.length;\n        int cols = grid[0].length;\n        PriorityQueue<Info> threatenAreas = new PriorityQueue<Info>((a,b)->b.threatenArea.size()-a.threatenArea.size());\n        for(int i=0; i<rows; i++){\n            for(int j=0; j<cols; j++){\n                if(grid[i][j] == 1){\n                    Set<Integer> threatenArea = new HashSet();\n                    Set<Integer> origArea = new HashSet();\n                    int wallsToBuild = dfs(i, j, grid, threatenArea, origArea);\n                    if(threatenArea.size()>0)\n                        threatenAreas.offer(new Info(wallsToBuild, threatenArea, origArea));\n                }\n            }\n        }\n        if(threatenAreas.isEmpty()) return res;\n        Info largestArea = threatenAreas.poll();\n        res += largestArea.wallsToBuild;\n        buildWalls(largestArea.origArea, grid);\n        while(!threatenAreas.isEmpty()){\n            Info nextArea = threatenAreas.poll();\n            Set<Integer> origThreatenArea = nextArea.threatenArea;\n            Set<Integer> newArea = new HashSet();\n            Iterator<Integer> iter = origThreatenArea.iterator();\n            while(iter.hasNext()){\n                int pos = iter.next();\n                int i = pos/51;\n                int j = pos%51;\n                grid[i][j] = 1;\n            }    \n        }\n        resetGrid(grid);\n        return containVirus(grid);\n    }\n    \n    public void resetGrid(int[][] grid){\n        int rows = grid.length;\n        int cols = grid[0].length;\n        for(int i=0; i<rows; i++){\n            for(int j=0; j<cols; j++){\n                if(grid[i][j] > 0)\n                    grid[i][j] = 1;\n            }\n        }\n    }\n    \n    public void buildWalls(Set<Integer> area, int[][] grid){\n        Iterator<Integer> iter = area.iterator();\n        while(iter.hasNext()){\n            int next = iter.next();\n            grid[next/51][next%51] = -1;\n        }\n    }\n    \n    public int dfs(int i, int j, int[][] grid, Set<Integer> threatenArea, Set<Integer> origArea){\n        if(i < 0 || j < 0 || i == grid.length || j == grid[0].length || grid[i][j] == 2 || grid[i][j] == -1)\n            return 0;\n        if(grid[i][j] == 0){\n            threatenArea.add(i*51 + j);\n            return 1;\n        }\n        origArea.add(i*51+j);\n        grid[i][j] = 2;\n        int res = 0;\n        res += dfs(i-1, j, grid, threatenArea, origArea);\n        res += dfs(i+1, j, grid, threatenArea, origArea);\n        res += dfs(i, j-1, grid, threatenArea, origArea);\n        res += dfs(i, j+1, grid, threatenArea, origArea);\n        return res;\n    }\n}
[]