[java] backtrack
\nclass Solution {\n    int max=0;\n    public int maximumGood(int[][] statements) {\n        int n=statements.length;\n        int[] arr=new int[n]; //0 bad, 1
```\nclass Solution {\n    int max=0;\n    public int maximumGood(int[][] statements) {\n        int n=statements.length;\n        int[] arr=new int[n]; //0 bad, 1 good, 2 no statement\n        Arrays.fill(arr, 2);\n        dfs(0,arr,statements,n);\n        return max;\n    }\n    private void dfs(int index, int[] arr, int[][] statements, int n){\n        if (index>=n){\n            int res=0;\n            for (int i=0; i<n; i++){\n                if (arr[i]==1){\n                    res++;\n                }\n            }\n            max=Math.max(max,res);\n            return;\n        }\n            \n        int[] temp=arr.clone();\n        if (temp[index]==0){ // statement doesn\'t care\n            dfs(index+1, temp, statements,n);\n            return;\n        } else if (temp[index]==1){\n            int[] st=statements[index];\n            for (int i=0; i<n; i++){\n                if ((st[i]==0 && temp[i]==1) || (st[i]==1 && temp[i]==0)){\n                    return;\n                }\n                if (st[i]!=2) temp[i]=st[i];\n            }\n            dfs(index+1, temp, statements,n);\n            return;\n        } else {\n            temp[index]=0;\n            dfs(index+1, temp, statements, n);\n            temp[index]=1;\n            int[] st1=statements[index];\n            for (int i=0; i<n; i++){\n                if ((st1[i]==0 && temp[i]==1) || (st1[i]==1 && temp[i]==0)){\n                    return;\n                }\n                if (st1[i]!=2) temp[i]=st1[i];\n            }\n            dfs(index+1, temp, statements, n);\n        }\n    }\n}\n```
['Backtracking']