Choose any subset of entries from words using the characters available in letters. Each word entry may be selected at most once, and each occurrence in letters may be used at most once across all chosen words. You may leave letters unused or choose no words.
The array score gives the value of each lowercase letter: index 0 is for a, index 1 for b, and so on through z. A word's value is the sum of its character values, including repeated characters. Return the greatest total value of a valid selection of words. Identical words at different indices are separate available entries.
Example 1:
Input: words = ["ab","ac","b"]
letters = ["a","b","c"]
score = [2,3,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
Output: 9Explanation: Choose "ac" for 2 + 4 = 6 points and "b" for 3 points. Together they use each available letter once and score 9. Choosing "ab" instead would use the only a and prevent forming "ac".
Example 2:
Input: words = ["aa","a"]
letters = ["a","a"]
score = [5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
Output: 10Explanation: The two available a letters can form "aa", scoring 5 + 5 = 10. There are not enough letters to select both word entries.
Example 3:
Input: words = ["z"]
letters = ["a"]
score = [10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10]
Output: 0Explanation: The only word needs z, which is unavailable. Choose no words and return 0.
Constraints:
1 <= words.length <= 141 <= words[i].length <= 151 <= letters.length <= 100- Each entry of
lettersis exactly one character. score.length == 260 <= score[i] <= 10- All words and letters contain only lowercase English letters.