Clean and Concise Solution with Explaination.
Solution [AC]  DFS\n\nAny person \' i \' can either  be a good person or a bad person.\nHere the Approch is.\nTrying every possible combination of all persons (
**Solution [AC]  DFS**\n\nAny person \' i \' can either  be a good person or a bad person.\nHere the Approch is.\nTrying every possible combination of all persons (by making them good or bad) and if it satisfys all given statements then, we will update our ans if, our combination has more no. of good persons than previous answer.\n\n```\nclass Solution {\n    private int maxGoodPersons = 0;\n    public int maximumGood(int[][] s) {\n        solve(0, 0, new int[s.length], s);\n        return maxGoodPersons;\n    }\n    \n    private void solve(int currPerson, int goods, int[] isGoodPerson, int[][] s) {\n        \n        if(currPerson == isGoodPerson.length) {\n            if(isValid(isGoodPerson, s)) maxGoodPersons = Math.max(maxGoodPersons, goods);\n            return;\n        }\n        //Set currPerson as good person\n        isGoodPerson[currPerson] = 1;\n        solve(currPerson+1, goods+1, isGoodPerson, s);\n        \n        //Set currPerson as bad person\n        isGoodPerson[currPerson] = 0;\n        solve(currPerson+1, goods, isGoodPerson, s);  \n    }\n    \n    private boolean isValid(int[] isGoodPerson, int[][] s) {\n        \n        // If our combination does\'nt satisfy given statements then return false.\n         for(int i = 0; i < isGoodPerson.length; i++) {\n            // If i\'th person is bad then no need to check if his statements are satisfying or not because his stat\'s. might me right might be wrong.\n            if(isGoodPerson[i] == 0) continue; \n             \n            // If i\'s statemtn saying that j is good (or bad) and if it does\'nt match with our combination then our combination is not valid.\n            for(int j = 0; j < isGoodPerson.length; j++) if(s[i][j] != 2 && s[i][j] != isGoodPerson[j]) return false;\n         }\n        \n        return true;\n    }\n}\n\n```
['Depth-First Search', 'Recursion', 'Java']