Simple C++ Solution || (Bitmask) || Detailed explanation
\nApproach:\nlet n=3\nwe know that, a person can be good or bad --> there are two options only\n\np1  p2   p2\n2   2   2   ----> 2*2*2= 2^3 combinations\n\n000 
\n**Approach:**\nlet n=3\nwe know that, a person can be good or bad --> there are two options only\n```\np1  p2   p2\n2   2   2   ----> 2*2*2= 2^3 combinations\n```\n000   ---> bad bad bad\n001\n010\n011\n100\n101\n110\n111\n\nwe will only care about only good persons and ignore bad persons\nbcoz good persons will always tells truth.\n\nWe assume person i is good so he always speaks \ntruth so there are 2 possible contradictions :\n(i) Person i said that person j is good but we assume person j is bad so, here it contradict.\n\n(ii) Person i said that person j is bad but we assume person j is good so, here it contradict.\n\n\nif everything is okay (no contradiction)\nthen  just count the no. of good peoples in this combination\nSimilarly do for all combinations and return max of them.\n\n```\nclass Solution {\npublic:\n    int maximumGood(vector<vector<int>>& a) {\n        int ans = 0;\n        int n = a.size();\n        for (int mask = 0; mask < (1 << n); mask++)\n        {\n            bool can = true;\n            for (int i = 0; i < n; i++)\n            {\n                if (!(mask & (1 << i))) continue;  // if bad\n                for (int j = 0; j < n; j++)\n                {\n                    if (a[i][j] == 1)\n                    {  if (!(mask & (1 << j))) can = false; }\n\t\t\t\t\t\n                    if (a[i][j] == 0)\n                    {  if ((mask & (1 << j)))   can = false; }\n                }\n            }\n            if (can)  \n            {\n                int  curr = __builtin_popcount(mask);\n                ans= max(ans, curr);\n            }\n        }\n        return ans;\n    }\n};\n```\n
['C', 'Bitmask']