Find Words That Can Be Formed by Characters LeetCode solution in Python
1class Solution(object):2def countCharacters(self, words, chars):3"""4:type words: List[str]5:type chars: str6:rtype: int7"""8b = set(chars)9anwser = 010for i in words:11a = set(i)12if a.issubset(b):13test = [o for o in a if chars.count(o) < i.count(o)]14if len(test) == 0:15anwser += len(i)16return anwser