1684.cpp (463B)
1 class Solution { 2 public: 3 int countConsistentStrings(const string &allowed, const vector<string> &words) const { 4 bool count[26] = {false}; 5 int res = 0; 6 7 for (const char c : allowed) 8 count[c - 'a'] = true; 9 for (const auto &word : words) { 10 for (const char c : word) { 11 if (!count[c - 'a']) goto next; 12 } 13 res++; 14 next:; 15 } 16 17 return res; 18 } 19 };