8 vector<string>
wordSubsets(vector<string>& words1, vector<string>& words2)
10 vector<int> total_occurrences(26, 0);
11 vector<string> answer;
12 answer.reserve((
int)words1.size());
13 for (
string& word: words2)
15 vector<int> occurrences(26, 0);
17 occurrences[c -
'a']++;
18 for (
int i = 0; i < 26; ++i)
19 total_occurrences[i] = max(occurrences[i], total_occurrences[i]);
21 for (
string& word: words1)
23 vector<int> occurrences(26, 0);
25 occurrences[c -
'a']++;
27 for (
int i = 0; i < 26; ++i)
29 if (occurrences[i] < total_occurrences[i])
36 answer.push_back(word);