Beat 100.00%
For each person make an assumption whether they are good or bad. Keep recursing and try to detect contradictions based on the most recent assumption.\n\nA list 
For each person make an assumption whether they are good or bad. Keep recursing and try to detect contradictions based on the most recent assumption.\n\nA list `known` contains our assumptions. The most recent assumption is `known[-1]` which we compare to all previous assumption. If any assumption about person `i` is `good` then `statement[i][j]` must be `2` (= no statement) or the assumption we made about that person previously.\n\nA simple trick improved the performance from 330 ms to just 42ms:\nif there are still some assumptions to be made but we already known that even if ALL upcoming assumptions are `good` we can\'t find a better solution then avoid recursing any further.\nThe simple comparison `result - known.count(good) < len(statements) - len(known)` does that job (my actual code is slightly different: `result - citizens < size - length`)\n\n# Code\n```\nclass Solution:\n    def maximumGood(self, statements: List[List[int]]) -> int:\n        result = 0\n        size   = len(statements)\n\n        # constants\n        bad    = 0\n        good   = 1\n        either = 2\n\n        def deeper(known):\n            length = len(known)\n            person = length - 1\n\n            # check whether most recent assumption matches all related statements\n            for other in range(length):\n                # reveal contradictions\n                if known[person] == good and statements[person][other] not in ( known[other],  either ):\n                    return\n                if known[other ] == good and statements[other][person] not in ( known[person], either ):\n                    return\n\n            # good people\n            citizens = known.count(good)\n\n            nonlocal result\n            if length < size:\n                # next person\n                if result - citizens < size - length: # only if possible to improve\n                    deeper(known + [ good ])\n                    deeper(known + [ bad  ])\n            else:\n                result = max(result, citizens)\n\n        deeper([])\n        return result\n```
['Python3']