[Python3] Just Working Code - 27.09.2024
\npython3 []\nclass Solution:\n    def maximumGood(self, statements: List[List[int]]) -> int:\n        n = len(statements)\n        hm_good = {i: set([i]) for i
\n```python3 []\nclass Solution:\n    def maximumGood(self, statements: List[List[int]]) -> int:\n        n = len(statements)\n        hm_good = {i: set([i]) for i in range(n)}\n        hm_bad = {i: set() for i in range(n)}\n        for i in range(n):\n            for j in range(n):\n                if statements[i][j] == 0:\n                    hm_bad[i].add(j)\n                elif statements[i][j] == 1:\n                    hm_good[i].add(j)\n        def helper(i, good, bad):\n            if i == n:\n                return len(good) if not good.intersection(bad) else -1\n            if i in bad:\n                return helper(i+1, good, bad)\n            if hm_good[i].intersection(bad) or hm_bad[i].intersection(good):\n                if i in good:\n                    return -1\n                return helper(i+1, good, bad.union(set([i])))\n            return max(helper(i+1, good, bad.union(set([i]))), \\\n            helper(i+1, good.union(hm_good[i]), bad.union(hm_bad[i])))\n        return helper(0, set(), set())\n```
['Python3']