Count the Number of Consistent Strings LeetCode solution in C++
1class Solution {2public:3int countConsistentStrings(string allowed, vector<string> &words) {4// support variable5int res = words.size();6bool alpha[26] = {};7// populating alpha8for (char c : allowed) alpha[c - 'a'] = true;9// parsing all the words to see if each character is in alpha10for (string word : words) {11// in case we find an unallowed character, we decrease res and break12for (char c : word)13if (!alpha[c - 'a']) {14res--;15break;16}17}18return res;19}20};