2023-09-22 08:27:41 +0000 UTC

Count the Number of Consistent Strings

Code

class Solution:
    def countConsistentStrings(self, allowed: str, words: List[str]) -> int:
        allowed = set(allowed)
        count = 0
        for word in words:
            if not set(word) - allowed:
                count += 1
        return count