给你一个由不同字符组成的字符串 allowed 和一个字符串数组 words 。如果一个字符串的每一个字符都在 allowed 中,就称这个字符串是 一致字符串 。
请你返回 words 数组中 一致字符串 的数目。
来源:力扣(LeetCode)
链接:https://leetcode.cn/problems/count-the-number-of-consistent-strings
著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。

思路:直接找。
python3实现:
class Solution:
def countConsistentStrings(self, allowed: str, words: List[str]) -> int:
list_allowed = list(allowed)
count = 0
for elem in words:
dic_elem = collections.Counter(elem)
tmp = 0
std = len(dic_elem)
for k in dic_elem:
if k not in list_allowed:
break
else:
tmp += 1
if tmp == std:
count += 1
return count
