1684. Count the Number of Consistent Strings

Обновлено: 2024-03-12
1 мин
[]

Содержание

LeetCode problem 1684

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)