C++ easy and optimal solution using bitmask
Intuition\nDue to the light constraints we can try with every combination of good people.\n\n# Approach\nFor checking whether a combination is valid or not, we 
# Intuition\nDue to the light constraints we can try with every combination of good people.\n\n# Approach\nFor checking whether a combination is valid or not, we need to check the statement of the good people is correct.\nIf their is no contradiction in statements of good people, we can count the good people in that combination and take the maximum with our result.\n\n# Complexity\n- Time complexity: O(2^N * N^2)\n\n\n- Space complexity: O(1)\n\n# Code\n```\nclass Solution {\npublic:\n    bool isPossible(int mask, vector<vector<int>>& v)\n    {\n        int n = v.size();\n        for(int i = 0; i < n; i++)\n        {\n            // Assuming ith person is good\n            if(mask >> i & 1)\n            {\n                // then all his statements shoud be true\n                for(int j = 0; j < n; j++)\n                {\n                    bool good = mask >> j & 1;\n                    if(v[i][j] == 2) continue;\n                    // if his statement contradicts\n                    if(v[i][j] ^ good)\n                        return false;\n                }\n            }\n        }\n        return true;\n    }\n    int maximumGood(vector<vector<int>>& v) {\n        int n = v.size();\n        int mask = (1 << n) - 1;\n        int res = 0;\n        // trying all possible combinations of good people\n        while(mask >= 0)\n        {\n            if(isPossible(mask, v))\n                res = max(res, __builtin_popcount(mask));\n            mask--;\n        }\n        return res;\n    }\n};\n```
['C++']