Bitmasking | C++ | O(n^2 * 2^n)
\nclass Solution {\npublic:\n   // bool isvalid\n    int isvalid(int key,vector<vector<int>>&statements,int n){\n        vector<int>gb(n,0);\n        int count=
```\nclass Solution {\npublic:\n   // bool isvalid\n    int isvalid(int key,vector<vector<int>>&statements,int n){\n        vector<int>gb(n,0);\n        int count=0;\n        for(int i=0;i<n;i++){\n            if(key & (1<<i))\n                gb[i]++,count++;\n            \n        }\n        for(int i=0;i<n;i++){\n            if(gb[i]==1){\n                for(int j=0;j<n;j++){\n                    if((statements[i][j]==1 && gb[j]==0) ||(statements[i][j]==0 && gb[j]==1))return 0;\n                }\n            }\n        }\n        \n        \n        return count;\n        \n        \n    }\n    int maximumGood(vector<vector<int>>& statements) {\n        int n=statements.size();\n    \n        int ans=0;\n        for(int i=0;i<(1<<n);i++){\n            ans=max(ans,isvalid(i,statements,n));\n        }\n        return ans;\n    }\n};\n```
[]