Talentd
FleetCode

1002. Find Common Characters

Easy74.6% acceptance6 companies

Given a string array words, return an array of all characters that show up in all strings within the words (including duplicates). You may return the answer in any order.

Example 1:

Input: words = ["bella","label","roller"]
Output: ["e","l","l"]

Example 2:

Input: words = ["cool","lock","cook"]
Output: ["c","o"]

Constraints:

  • 1 <= words.length <= 100
  • 1 <= words[i].length <= 100
  • words[i] consists of lowercase English letters.
9:24
Still stuck?Read 3 approaches, or watch a walkthrough.
Open solution
Loading editor…
1class Solution:
2 def commonChars(self, words: List[str]) -> List[str]:
3
Starter codePython 3Spaces: 4
Examples
Input
["bella","label","roller"]
Input
["cool","lock","cook"]
Your code is saved on this device.Solution