
Find Common Characters (easy)
Problem Statement
Given a strings array words, return a character array results containing all characters (including duplicates), which are common in all strings of words. You may return characters in any order.
Examples
-
Example 1:
- Input: words =
["glean","angle","angel","galen","lange"] - Expected Output:
["a","e","g","l","n"] - Justification: The letters 'a', 'e', 'g', 'l', and 'n' are present in all five words. Each of these letters appears at least once in every word, making them common to all strings.
- Input: words =
-
Example 2:
- Input: words =
["danday","candya","ahand"] - Expected Output:
["a","a","d","n"] - Justification: The letters 'a', 'a', 'd', and 'n' are common in all three words, each appearing at least once in every word.
- Input: words =
-
Example 3:
- Input: words =
["race","care","ac"] - Expected Output:
["a","c""] - Justification: The letters 'a', and 'c' are present in all three words. Each of these letters appears at least once in every word, so they are included in the output list.
- Input: words =
Try it yourself
Try solving this question here:
Python3
Python3
. . . .
.....
.....
.....
Unlock this and all other premium problems.
No code editor for this lesson
This lesson focuses on concepts and theory