Find Common Characters

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

30:00

Find Common Characters
easy
Free written solution
Topics
Companies

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

Example 1:
Input: {"words":["bella","label","roller"]}
Output: ["e","l","l"]
Constraints:
  • 1≤words.length≤1001 \leq \text{words.length} \leq 100

  • 1≤words[i].length≤1001 \leq \text{words}[i]\text{.length} \leq 100

  • words[i] consists of lowercase English letters.

Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result

Run code to see results.

Input
arr ={"words":["bella","label","roller"]}

Start every letter at infinity. Each word can only lower a letter's shared count, never raise it.

words (3)

bella
label
roller

■ common (min so far)

■ this word

▭ cut by min

∞

a

∞

b

∞

e

∞

l

result

empty

Variables
VariableValue
commona:∞ b:∞ e:∞ l:∞
DepthFunction Call
Stack empty
0/9