1
# Runtime: 87 ms (Top 42.12%) | Memory: 14.3 MB (Top 6.17%)3
def _get_char_counts(self, s: str) -> dict[str]:4
"""builds a dict of letters : count"""10
def commonChars(self, words: list[str]) -> list[str]:11
"""returns a string of letters common between a list of words (including duplicates)"""16
words = [self._get_char_counts(word) for word in words]18
# O(nm), set intersection19
common = words[0].keys()20
for other in words[1:]:21
common &= other.keys()23
# O(nm), number of common characters across the number of words26
result += [c] * min(count[c] for count in words)