DFS Java in 40 lines
\npublic int maximumGood(int[][] statements) {\n\tint[] known = new int[statements.length];\n\tArrays.fill(known, 2);\n\treturn max(statements, known, 0);\n}\np
```\npublic int maximumGood(int[][] statements) {\n\tint[] known = new int[statements.length];\n\tArrays.fill(known, 2);\n\treturn max(statements, known, 0);\n}\nprivate int max(int[][] statements, int[] known, int position) {\n\tif(position == statements.length) return (int) Arrays.stream(known).filter(a -> a == 1).count();\n\tswitch(known[position]) {\n\t\tcase 0:\n\t\t\treturn assumeBad(statements, known, position);\n\t\tcase 1:\n\t\t\treturn assumeGood(statements, known, position);\n\t\tdefault:\n\t\t\treturn Math.max(assumeBad(statements, known, position), assumeGood(statements, known, position));\n\t}\n}\nprivate int assumeBad(int[][] statements, int[] known, int position) {\n\tint[] updatedKnown = known.clone();\n\tupdatedKnown[position] = 0;\n\treturn max(statements, updatedKnown, position + 1);\n}    \nprivate int assumeGood(int[][] statements, int[] known, int position) {\n\tint[] updatedKnown = known.clone();\n\tboolean conflictDetected = false;\n\tupdatedKnown[position] = 1;\n\tfor(int i = 0; i<statements[position].length; i++) {\n\t\tint answer = statements[position][i];\n\t\tif(answer == 2) continue;\n\t\tif(known[i] != 2 && answer != known[i]) { \n\t\t\tconflictDetected = true;\n\t\t\tbreak;\n\t\t}\n\t\tupdatedKnown[i] = answer;            \n\t}\n\treturn conflictDetected ? 0 : max(statements, updatedKnown, position + 1);\n}\n```
['Java']