Find Common Characters
Easy · Array, Hash Table, String
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.
Starter code (python)
class Solution(object):
def commonChars(self, words):
"""
:type words: List[str]
:rtype: List[str]
"""
Related problems
- Two Sum (Easy)
- Longest Substring Without Repeating Characters (Medium)
- Median of Two Sorted Arrays (Hard)
Previous: Maximum Binary Tree II · Next: Check If Word Is Valid After Substitutions · All problems
Zepruv is a technical interview practice platform. Read any problem for free; sign in to run your code, submit and keep your progress.