C++ | 100 % TC
cpp\nclass Solution {\n\n    int powers[15] = {1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384};\n\n    int numOfOnes(int i) {\n        int count = 0;\n 
```cpp\nclass Solution {\n\n    int powers[15] = {1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384};\n\n    int numOfOnes(int i) {\n        int count = 0;\n        while (i > 0) {\n            count += (i & 1);\n            i >>= 1;\n        }\n        return count;\n    }\n\n    bool isValid(vector<vector<int>>& statements, int currAssum, int n) {\n        for (int i = 0; i < n; ++i) {\n            if ((currAssum & powers[i]) == 0) {\n                continue;\n            }\n            for (int j = 0; j < n; ++j) {\n                if (statements[i][j] == 2) {\n                    continue;\n                }\n                if (statements[i][j] != ((currAssum & powers[j]) >> j)) {\n                    return false;\n                }\n            }\n        }\n        return true;\n    }\n\npublic:\n    int maximumGood(vector<vector<int>>& statements) {\n        int n = statements.size();\n        int maxAssum = pow(2, n);\n        int currCount;\n        int maxGood = 0;\n        for (int i = 0; i < maxAssum; ++i) {\n            currCount = numOfOnes(i);\n            if (currCount <= maxGood) {\n                continue;\n            }\n            if (isValid(statements, i, n)) {\n                maxGood = currCount;\n            }\n        }\n        return maxGood;\n    }\n};\n```
['Bit Manipulation', 'C', 'Bitmask']