3
int calc(vector<string> &words, map<char, int> &m, vector<int> &score, int i) {5
if (i == words.size()) return 0;6
map<char, int> m1 = m; // Creating a duplicate in case the given word does7
// not satisfy our answer8
int c = 0; // Store the score9
for (int j = 0; j < words[i].length(); j++) {10
if (m1.find(words[i][j]) == m1.end() ||11
m1[words[i][j]] == 0) { // If frequency of the letter reduces to zero or that letter12
// is not present in our hashMap16
c += score[words[i][j] - 'a'];20
maxi = c + (calc(words, m1, score,21
i + 1)); // We are considering the current word and22
// adding it to our answer23
return max(maxi, calc(words, m, score,24
i + 1)); // FInding tha maximum between when we consider the25
// current word and when we DONT consider current word27
int maxScoreWords(vector<string> &words, vector<char> &letters, vector<int> &score) {29
for (auto i : letters) m[i]++;30
return calc(words, m, score, 0);