1160. Find Words That Can Be Formed by Characters

Обновлено: 2024-03-12
1 мин
[]

Содержание

LeetCode problem 1160

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