Given an array of strings words, return an array containing every character that appears in each string in words, including duplicates. If a character occurs multiple times in all strings, include it in the result that many times. The returned characters may be in any order.
Constraints:
1≤ words.length ≤100
1≤ words[i].length ≤100
words[i] consists of lowercase English letters.
Input: words = ["bella","label","roller"]-List[str]
Output: ["e","l","l"]-List[str]
Explanation: The characters common to all three strings are e (once) and l (twice). Even though some words contain more occurrences, we include each character the minimum number of times it appears across all words.
Input: words = ["cool","lock","cook"]-List[str]
Output: ["c","o"]-List[str]
Explanation: c and o each appear in every word at least once, while other letters fail to appear in all strings.
Input: words = ["a","a","a"]-List[str]
Output: ["a"]-List[str]
Explanation: The only character is a, and it appears once in each string, so it appears once in the result.
Input: words = ["abbb","bbab","babb"]-List[str]
Output: ["a","b","b","b"]-List[str]
Explanation: Counting occurrences per word and taking the minimum per character across all words, a appears at least once in each word and b appears at least three times in each word, so the result includes one a and three bs.
Input: words = ["abc","def","ghi"]-List[str]
Output: []-List[str]
Explanation: No character appears in all strings, so the result is empty.
Now, let’s take a moment to make sure you’ve correctly understood the problem. The quiz below helps you check if you’re solving the correct problem: