给你一个由不同字符组成的字符串 allowed 和一个字符串数组 words 。如果一个字符串的每一个字符都在 allowed 中,就称这个字符串是 一致字符串 。
请你返回 words 数组中 一致字符串 的数目。
class Solution:
def countConsistentStrings(self, allowed: str, words: List[str]) -> int:
count = 0
for item in words:
flag=True
for c in item:
if c not in allowed:
flag = False
if flag:
count +=1
return count