Java clean
Very short Java\n\n1. we calculate score of island(means how many island it can infect next), border of island\n2. pick the max score island and delete it, add 
Very short Java\n\n1. we calculate score of island(means how many island it can infect next), border of island\n2. pick the max score island and delete it, add border of that island to result\n3. extend infection to next day, all remaining island expand.\n\n```\nclass Solution {\n    int m, n, id;\n    int[][] dirs = {{-1, 0}, {1, 0}, {0, 1}, {0, -1}};\n    public int containVirus(int[][] grid) {\n        m = grid.length; n = grid[0].length; \n        int res = 0;\n        while (true) {\n            id = 0;\n            Set<Integer> visited = new HashSet<>();\n            Map<Integer, Set<Integer>> islands = new HashMap<>(), scores = new HashMap<>();\n            Map<Integer, Integer> walls = new HashMap<>();\n            for (int i = 0; i < m; i++) \n                for (int j = 0; j < n; j++)\n                    if (grid[i][j] == 1 && !visited.contains(i * n + j))\n                        dfs(i, j, visited, grid, islands, scores, walls, id++);\n            if (islands.isEmpty()) break;\n            int maxVirus = 0;\n            for (int i = 0; i < id; i++)\n                if (scores.getOrDefault(maxVirus, new HashSet<>()).size() < scores.getOrDefault(i, new HashSet<>()).size())\n                    maxVirus = i;\n            res += walls.getOrDefault(maxVirus, 0);\n            for (int i = 0; i < islands.size(); i++)\n                for (int island : islands.get(i)) {\n                    int x = island / n, y = island % n;\n                    if (i == maxVirus) grid[x][y] = -1; \n                    else {                             \n                        for (int [] dir : dirs) {\n                            int nx = x + dir[0], ny = y + dir[1];\n                            if (nx >= 0 && nx < m && ny >= 0 && ny < n && grid[nx][ny] == 0) \n                                grid[nx][ny] = 1;\n                        }\n                    }                           \n                }\n        }\n        return res;\n    }\n    \n    private void dfs(int i, int j, Set<Integer> visited, int[][] grid, Map<Integer, Set<Integer>> islands, Map<Integer, Set<Integer>> scores, Map<Integer, Integer> walls, int id) {\n        if (!visited.add(i * n + j)) return;\n        islands.computeIfAbsent(id, value -> new HashSet<>()).add(i * n + j);\n        for (int[] dir : dirs) {\n            int x = i + dir[0], y = j + dir[1];\n            if (x < 0 || x >= m || y < 0 || y >= n) continue;\n            if (grid[x][y] == 1) dfs(x, y, visited, grid, islands, scores, walls, id);\n            if (grid[x][y] == 0) {\n                scores.computeIfAbsent(id, value -> new HashSet<>()).add(x * n + y);\n                walls.put(id, walls.getOrDefault(id, 0) + 1);\n            }\n        }\n    }\n}\n```
[]