✅ Everything Explained Using Comment | Linear Solution | [Java | C++]
Java Code\n\nclass Solution {\n    public int countConsistentStrings(String allowed, String[] words) {\n        int res = words.length;  // Suppose initially al
# Java Code\n```\nclass Solution {\n    public int countConsistentStrings(String allowed, String[] words) {\n        int res = words.length;  // Suppose initially all words are Consistent\n        boolean[] alpha = new boolean[26];  //Default value false\n\n        // if allowed = "aef" then\n        // 1 0 0 0 1 1 0\n        // a b c d e f g\n        for(int i = 0;i < allowed.length(); i++)\n            alpha[allowed.charAt(i)-\'a\'] = true;  \n        \n        for(String str : words)  // Iterate over the all the Strings of words\n            for(int i = 0;i < str.length(); i++)\n                if(alpha[str.charAt(i)-\'a\'] == false)  // if alpha(str[i]-\'a\') == false  means it is not present in allowed so str is not a consistent string so decrement res--.\n                {\n                    res--;\n                    break;\n                }\n        return res;\n    }\n}\n```\n\n# C++ Code\n```\nclass Solution {\npublic:\n    int countConsistentStrings(string allowed, vector<string>& words) {\n        int res = words.size();  // Suppose initially all words are Consistent\n        bool alpha[26] = {};   //Default value false\n\n        // if allowed="aef" then\n        // 1 0 0 0 1 1 0\n        // a b c d e f g\n        \n        for(char c : allowed)\n            alpha[c-\'a\'] = true;\n        \n        for(string str : words)  // Iterate over the all the Strings of words\n            for(char c : str)\n                if(alpha[c-\'a\'] == false)  // if alpha(str[i]-\'a\')==false  means it is not present in allowed so str is not a consistent string so decrement res--.\n                {\n                    res--;\n                    break;\n                }\n        return res;\n    }\n};\n```
['String', 'C', 'C++', 'Java']