Skip to content

Commit

Permalink
Time: 171 ms (40.44%), Space: 16.8 MB (49.96%) - LeetHub
Browse files Browse the repository at this point in the history
  • Loading branch information
hovanhoa committed Dec 2, 2023
1 parent bf7cfc2 commit c70c654
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit c70c654

Please sign in to comment.