C++ || Check the combination || Easy to understand || Bitmask
Generate all combinations using bitmask where the mask tells that who all are speaking truth (1->truth, 0->lying). \n Now you just need to check that all the pe
* Generate all combinations using bitmask where the mask tells that who all are speaking truth (1->truth, 0->lying). \n* Now you just need to check that all the people who we assumed are speaking truth, their statements should not contradict. i.e. if 3rd person says 1 and 2 and bad people and in our mask if 1 and 2 are not bad(not 0), then this configuration is invalid.\n* You just need to check this for all.\n\n```\nclass Solution {\npublic:\n    vector<string> DP[16][16];\n    void findBitCombinations(int k){\n\t    string str = "";\n\t    for (int len = 0; len <= k; len++){\n\t\t    DP[len][0].push_back(str);\n\t\t    str = str + "0";\n\t    }\n\t    for (int len = 1; len <= k; len++)\n\t    {\n\t\t    for (int n = 1; n <= len; n++)\n\t\t    {\n\t\t\t    for (string str : DP[len - 1][n])\n\t\t\t\t    DP[len][n].push_back("0" + str);\n\t\t\t    for (string str : DP[len - 1][n - 1])\n\t\t\t\t    DP[len][n].push_back("1" + str);\n\t\t    }\n\t    }\n\t\n    }\n    \n    bool ok(string str, vector<vector<int>>& stm){\n        //010--> 0,1,2\n        int n=str.size();\n        for(int i=0;i<n;i++){\n            if(str[i]==\'1\'){\n                for(int j=0;j<n;j++){\n                    if(stm[i][j]!=2 and stm[i][j]!=(str[j]-\'0\'))\n                        return false;\n                }\n            }\n        }\n        return true;\n    }\n    int maximumGood(vector<vector<int>>& stm) {\n        int k=stm.size();\n        int ans=0;\n        findBitCombinations(k);\n        for (int n = k; n >=1; n--){\n\t\t    for (string str : DP[k][n]){\n                if(ok(str, stm)){\n                    return n;\n                }\n            }\n\t    }   \n        return ans;\n    }\n};\n```
['Bitmask']