Time: 296 ms (15.20%), Space: 18.3 MB (22.11%) - LeetHub

This commit is contained in:
Deven
2023-05-15 21:19:44 -04:00
parent d19ebecf97
commit 4fd80ba442
@@ -0,0 +1,19 @@
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