[Python3] brute-force
\n\nclass Solution:\n    def containVirus(self, isInfected: List[List[int]]) -> int:\n        m, n = len(isInfected), len(isInfected[0])\n        ans = 0 \n    
\n```\nclass Solution:\n    def containVirus(self, isInfected: List[List[int]]) -> int:\n        m, n = len(isInfected), len(isInfected[0])\n        ans = 0 \n        while True: \n            regions = []\n            fronts = []\n            walls = []\n            seen = set()\n            for i in range(m): \n                for j in range(n): \n                    if isInfected[i][j] == 1 and (i, j) not in seen: \n                        seen.add((i, j))\n                        stack = [(i, j)]\n                        regions.append([(i, j)])\n                        fronts.append(set())\n                        walls.append(0)\n                        while stack: \n                            r, c = stack.pop()\n                            for rr, cc in (r-1, c), (r, c-1), (r, c+1), (r+1, c): \n                                if 0 <= rr < m and 0 <= cc < n: \n                                    if isInfected[rr][cc] == 1 and (rr, cc) not in seen: \n                                        seen.add((rr, cc))\n                                        stack.append((rr, cc))\n                                        regions[-1].append((rr, cc))\n                                    elif isInfected[rr][cc] == 0: \n                                        fronts[-1].add((rr, cc))\n                                        walls[-1] += 1\n            if not regions: break\n            idx = fronts.index(max(fronts, key = len))\n            ans += walls[idx]\n            for i, region in enumerate(regions): \n                if i == idx: \n                    for r, c in region: isInfected[r][c] = -1 # mark as quaranteened \n                else: \n                    for r, c in fronts[i]: isInfected[r][c] = 1 # mark as infected \n        return ans \n```
['Python3']