Find Common Characters - Problem

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.

For example, if a character occurs 3 times in each string and 2 times in another string, you should include that character 2 times in the final answer (the minimum occurrence across all strings).

Input & Output

Example 1 — Basic Case
$ Input: words = ["bella","label","roller"]
Output: ["e","l","l"]
💡 Note: Character 'e' appears once in each word, 'l' appears twice in each word, so result is ["e", "l", "l"]
Example 2 — Different Frequencies
$ Input: words = ["cool","lock","cook"]
Output: ["c","o"]
💡 Note: Character 'c' appears once in each word, 'o' appears twice in 'cool' and 'cook' but once in 'lock', so we take minimum count of 1
Example 3 — No Common Characters
$ Input: words = ["abc","def","ghi"]
Output: []
💡 Note: No characters appear in all three words, so result is empty array

Constraints

  • 1 ≤ words.length ≤ 100
  • 1 ≤ words[i].length ≤ 100
  • words[i] consists of lowercase English letters.

Visualization

Tap to expand
Find Common Characters: Input → Process → OutputInput Strings"bella""label""roller"Character Analysise: appears 1,1,1 timesl: appears 2,2,2 timesb: appears 1,1,0 timesCommon Characterse: min(1,1,1) = 1l: min(2,2,2) = 2b: min(1,1,0) = 0 ✗Result: ["e", "l", "l"]✓ Only characters present in ALL strings with minimum frequencies
Understanding the Visualization
1
Input Analysis
Array of strings with various characters
2
Find Common
Identify characters present in every string
3
Minimum Count
Take minimum frequency across all strings
Key Takeaway
🎯 Key Insight: The result is limited by whichever string has the fewest occurrences of each character
Asked in
Google 15 Amazon 12 Facebook 8
28.5K Views
Medium Frequency
~15 min Avg. Time
892 Likes
Ln 1, Col 1
Smart Actions
💡 Explanation
AI Ready
💡 Suggestion Tab to accept Esc to dismiss
// Output will appear here after running code
Code Editor Closed
Click the red button to reopen