1160. Find Words That Can Be Formed by Characters
On This Page
class Solution:
def countCharacters(self, words: List[str], chars: str) -> int:
cnt = Counter(chars)
res = 0
for w in words:
wc = Counter(w)
if all(cnt[c] >= v for c, v in wc.items()):
res += len(w)
return res