mirror of
https://github.com/devenperez/leetcode.git
synced 2026-06-13 14:57:08 +00:00
19 lines
600 B
Python
19 lines
600 B
Python
class Solution:
|
|
def countConsistentStrings(self, allowed: str, words: List[str]) -> int:
|
|
allowedFilter = [False] * 26
|
|
for c in allowed:
|
|
allowedFilter[ord(c) - ord('a')] = True
|
|
|
|
numAllowedWords = 0
|
|
for i in range(len(words)):
|
|
allowedWord = True
|
|
for a in words[i]:
|
|
if not allowedFilter[ord(a) - ord('a')]:
|
|
allowedWord = False
|
|
break
|
|
|
|
if allowedWord:
|
|
numAllowedWords += 1
|
|
|
|
|
|
return numAllowedWords |