1684. Count the Number of Consistent Strings
On This Page
class Solution:
def countConsistentStrings(self, allowed: str, words: List[str]) -> int:
def f(w):
return reduce(or_, (1 << (ord(c) - ord('a')) for c in w))
mask = f(allowed)
return sum((mask | f(w)) == mask for w in words)