1684. Count the Number of Consistent Strings ¶ Time: Space: C++JavaPython 1 2 3 4 5 6 7 8 9 10 11class Solution { public: int countConsistentStrings(string allowed, vector<string>& words) { return accumulate(words.begin(), words.end(), 0, [&allowed](int subtotal, const string& word) { return subtotal + ranges::all_of(word, [&allowed](char c) { return allowed.find(c) != string::npos; }); }); } }; 1 2 3 4 5 6 7class Solution { public int countConsistentStrings(String allowed, String[] words) { return (int) Arrays.stream(words) .filter(word -> word.matches(String.format("[%s]*", allowed))) .count(); } } 1 2 3 4class Solution: def countConsistentStrings(self, allowed: str, words: list[str]) -> int: return sum(all(c in allowed for c in word) for word in words)