Skip to content

Latest commit

 

History

History
40 lines (27 loc) · 1010 Bytes

_1160. Find Words That Can Be Formed by Characters.md

File metadata and controls

40 lines (27 loc) · 1010 Bytes

All prompts are owned by LeetCode. To view the prompt, click the title link above.

Back to top


First completed : September 24, 2024

Last updated : September 24, 2024


Related Topics : Array, Hash Table, String, Counting

Acceptance Rate : 70.74 %


Solutions

Python

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