Bitmask Iteration | Python
\n# Code\n\nfrom typing import List\n\n\nclass Solution:\n\tdef maximumGood(self, statements: List[List[int]]) -> int:\n\t\tn = len(statements)\n\n\t\tdef corre
\n# Code\n```\nfrom typing import List\n\n\nclass Solution:\n\tdef maximumGood(self, statements: List[List[int]]) -> int:\n\t\tn = len(statements)\n\n\t\tdef correct(mask):\n\t\t\tfor p in range(n):\n\t\t\t\tfor q in range(n):\n\t\t\t\t\tif not (\n\t\t\t\t\t\t\tstatements[p][q] == 2 or\n\t\t\t\t\t\t\t(mask >> p & 1) == 0 or\n\t\t\t\t\t\t\t(mask >> q & 1) == statements[p][q]):\n\t\t\t\t\t\treturn False\n\t\t\treturn True\n\n\t\tans = 0\n\t\tfor mask in range(1 << n):\n\t\t\tif correct(mask):\n\t\t\t\tans = max(ans, mask.bit_count())\n\t\treturn ans\n\n```
['Python3']