Skip to content

Latest commit

 

History

History
52 lines (36 loc) · 1.22 KB

_1002. Find Common Characters.md

File metadata and controls

52 lines (36 loc) · 1.22 KB

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

Back to top


First completed : June 08, 2024

Last updated : July 04, 2024


Related Topics : Array, Hash Table, String

Acceptance Rate : 74.63 %


Solutions

Python

# Daily
# Doing this with bad wifi so I can barely submit so idc about efficiency lol

class Solution:
    def commonChars(self, words: List[str]) -> List[str]:
        cnter = []

        for word in words :
            cnter.append(Counter(word))

        output = []
        primary = cnter[0]

        for ky in primary.keys() :
            minn = primary[ky]
            for i in range(1, len(cnter)) :
                if cnter[i].get(ky, 0) == 0 :
                    minn = 0
                    break
                minn = min(cnter[i].get(ky, 0), minn)
            output += [ky] * minn

        return output