Faster than 100% || Iterative || Intuitive || Easy to Understand || Beginner Friendly
\n# Approach\nallowed = "ab", words = ["ad","bd","aaab","baa","badab"]\nmax count = words.length = 5 (which is the max possible answer)\n\nThe real magic happen
\n# Approach\nallowed = "ab", words = ["ad","bd","aaab","baa","badab"]\nmax count = words.length = 5 (which is the max possible answer)\n\nThe real magic happens with the below mentioned line:\n\n```\nif(arr[ch-\'a\']<=0){ \n                    count--;\n                    break;\n                   } \n\n```\n\nOn iterating every character of words, we\'ll check the consistency, if not found we\'ll decrement the count by 1 .\n\nPs: Do upvote if this helped you in any way ;)\n\n# Code\n```\nclass Solution {\n    public int countConsistentStrings(String allowed, String[] words) {\n        int count = words.length; // max possible length of words array \n        int arr[] = new int[26];\n        for(int i=0;i<allowed.length();i++){\n            arr[allowed.charAt(i)-\'a\']++;\n        }\n\n        for(String str : words){\n            for(char ch: str.toCharArray()){\n                if(arr[ch-\'a\']<=0){ // if any character of \'words\' is not present in \'allowed\', reduce count\n                    count--;\n                    break;\n                }\n\n            }\n        }\n\n        return count;\n    }\n}\n```
['Array', 'Java']