All prompts are owned by LeetCode. To view the prompt, click the title link above.
First completed : September 24, 2024
Last updated : September 24, 2024
Related Topics : Array, Hash Table, String, Counting
Acceptance Rate : 70.74 %
class Solution:
def countCharacters(self, words: List[str], chars: str) -> int:
chars = Counter(chars)
output = 0
for word in words :
wordCnt = Counter(word)
if all(wordCnt[x] <= chars[x] for x in wordCnt) :
output += len(word)
return output