[C++] Bitwise Operation
Compute the mask of allowed (inverted) and word to check if there is any inconsistent character.\n\n\nclass Solution {\npublic:\n    int countConsistentStrings(
Compute the mask of allowed (inverted) and word to check if there is any inconsistent character.\n\n```\nclass Solution {\npublic:\n    int countConsistentStrings(string allowed, vector<string>& words) {\n        // assumed: all char are lowercase\n        // the entire mask is inverted to check the char that are not consistent\n        int mask_allowed = 0;\n        for (char c : allowed) mask_allowed |= (1 << (c - \'a\'));\n        \n        mask_allowed = ~mask_allowed;\n        \n        // check if consistent\n        int result = 0;\n        \n        for (string &word : words) {\n            int mask_word = 0;\n            for (char c : word) mask_word |= (1 << (c - \'a\'));\n            \n            if ((mask_word & mask_allowed) == 0) result++;\n        }\n        \n        return result;\n    }\n};\n```\n\nThanks for the correction by __10001001__, the newer version remove the redudant 0x3FFFFFF in statement ```mask_allowed = (~mask_allowed) & 0x3FFFFFF;```.
[]