mirror of
https://github.com/devenperez/leetcode.git
synced 2026-06-13 03:27:07 +00:00
Time: 296 ms (15.20%), Space: 18.3 MB (22.11%) - LeetHub
This commit is contained in:
+19
@@ -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
|
||||
Reference in New Issue
Block a user