diff --git a/1112-find-words-that-can-be-formed-by-characters/1112-find-words-that-can-be-formed-by-characters.py b/1112-find-words-that-can-be-formed-by-characters/1112-find-words-that-can-be-formed-by-characters.py new file mode 100644 index 0000000..abdf5e3 --- /dev/null +++ b/1112-find-words-that-can-be-formed-by-characters/1112-find-words-that-can-be-formed-by-characters.py @@ -0,0 +1,9 @@ +class Solution: + def countCharacters(self, words: List[str], chars: str) -> int: + result = 0 + char_count = Counter(chars) + for word in words: + word_count = Counter(word) + if all(word_count[char] <= char_count[char] for char in word): + result += len(word) + return result \ No newline at end of file