Count the Number of Consistent Strings LeetCode solution in Python

1
# Runtime: 236 ms (Top 95.16%) | Memory: 16 MB (Top 85.69%)
2
class Solution:
3
def countConsistentStrings(self, allowed: str, words: List[str]) -> int:
4
allowed = set(allowed)
5
count = 0
6

7
for word in words:
8
for letter in word:
9
if letter not in allowed:
10
count += 1
11
break
12

13
return len(words) - count

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0