Unable to find issue in code. Failing test case added
\nclass Solution {\n    public int containVirus(int[][] isInfected) {\n        int m = isInfected.length;\n        int n = isInfected[0].length;\n        int[] 
```\nclass Solution {\n    public int containVirus(int[][] isInfected) {\n        int m = isInfected.length;\n        int n = isInfected[0].length;\n        int[] dx = {0, 0, 1, -1};\n        int[] dy = {1, -1, 0, 0};\n        int total = 0;\n        int count = 0;\n        int maxWalls = 0;\n        print(isInfected, m, n);\n        do {\n            DSU dsu = new DSU(m*n);\n            for (int i = 0; i < m; i++) {\n               for (int j = 0; j < n; j++) {\n                   if (isInfected[i][j] == 1) {\n                      for (int k = 0; k < 4; k++) {\n                        int x = i + dx[k];\n                        int y = j + dy[k];\n                        if (isInBorder(m, n, x, y) && isInfected[x][y] == 1) {\n                            dsu.unionBySize(i*n + j, x*n + y);\n                        }\n                      }\n                   }\n                } \n            }\n            Map<Integer, List<int[]>> components = new HashMap<>();\n            for (int i = 0; i < m; i++) {\n               for (int j = 0; j < n; j++) {\n                   if (isInfected[i][j] == 1) {\n                      int group = dsu.findRepresentative(i*n + j);\n                      if (!components.containsKey(group)) {\n                           components.put(group, new ArrayList<>());\n                      }\n                      components.get(group).add(new int[]{i, j});\n                   }\n               }\n            }\n            maxWalls = 0;\n            int surroundGroup = 0;\n            for (Map.Entry<Integer, List<int[]>> entry : components.entrySet()) {\n                int walls = 0;\n                List<int[]> cells = entry.getValue();\n                for (int[] cell : cells) {\n                    for (int k = 0; k < 4; k++) {\n                        int x = cell[0] + dx[k];\n                        int y = cell[1] + dy[k];\n                        if (isInBorder(m, n, x, y) && isInfected[x][y] == 0) {\n                          walls++;\n                        }\n                    }  \n                }\n                if (maxWalls < walls) {\n                    surroundGroup = entry.getKey();\n                    maxWalls = walls;\n                }\n            }\n            if (maxWalls == 0) {\n                break;\n            }\n            System.out.println("maxWalls " + maxWalls);\n            total += maxWalls;\n            List<int[]> cellsToBlock = components.get(surroundGroup);\n            for (int[] cell : cellsToBlock) {\n                isInfected[cell[0]][cell[1]] = -1;\n            }\n            System.out.println("surroundGroup " + surroundGroup);\n            System.out.println("keys " + components.keySet());\n            components.remove(surroundGroup);\n            for (List<int[]> cells : components.values()) {\n                for (int[] cell : cells) {\n                    for (int k = 0; k < 4; k++) {\n                        int x = cell[0] + dx[k];\n                        int y = cell[1] + dy[k];\n                        if (isInBorder(m, n, x, y)) {\n                          isInfected[x][y] = 1;\n                        }\n                    } \n                }\n            }\n            print(isInfected, m, n);\n        } while(true);\n        return total;\n    }\n    \n    void print(int[][] isInfected, int m, int n) {\n        for (int i = 0; i < m; i++) {\n            for (int j = 0; j < n; j++) {\n                System.out.print(" " + isInfected[i][j]);\n            }\n            System.out.println();\n        }\n    }\n    \n    boolean isInBorder(int m, int n, int x, int y) {\n        if (x >=0 && y>=0 && x<m && y< n) {\n            return true;\n        }\n        return false;\n    }\n}\n\n\nclass DSU {\n    int representative [];\n    int size [];\n    \n    DSU(int sz) {\n        representative = new int[sz];\n        size = new int[sz];\n        \n        for (int i = 0; i < sz; ++i) {\n            // Initially each group is its own representative\n            representative[i] = i;\n            // Intialize the size of all groups to 1\n            size[i] = 1;\n        }\n    }\n    \n    // Finds the representative of group x\n    public int findRepresentative(int x) {\n        if (x == representative[x]) {\n            return x;\n        }\n        \n        // This is path compression\n        return representative[x] = findRepresentative(representative[x]);\n    }\n    \n    // Unite the group that contains "a" with the group that contains "b"\n    public void unionBySize(int a, int b) {\n        int representativeA = findRepresentative(a);\n        int representativeB = findRepresentative(b);\n        \n        // If nodes a and b already belong to the same group, do nothing.\n        if (representativeA == representativeB) {\n            return;\n        }\n        \n        // Union by size: point the representative of the smaller\n        // group to the representative of the larger group.\n        if (size[representativeA] >= size[representativeB]) {\n            size[representativeA] += size[representativeB];\n            representative[representativeB] = representativeA;\n        } else {\n            size[representativeB] += size[representativeA];\n            representative[representativeA] = representativeB;\n        }\n    }\n}\n```\n\nTest case which is failing:\n[[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,1,0,0],[1,0,0,0,0,0,0,0,0,0],[0,0,1,0,0,0,1,0,0,0],[0,0,0,0,0,0,1,0,0,0],[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,1,0],[0,0,0,0,1,0,1,0,0,0],[0,0,0,0,0,0,0,0,0,0]]
[]