Weighted Word Mapping
Problem Description
You are given an array of strings words, where each string represents a word containing lowercase English letters. You are also given an integer array weights of length 26, where weights[i] represents the weight of the -th lowercase English letter.
The weight of a word is defined as the sum of the weights of its characters.
For each word, take its weight modulo 26 and map the result to a lowercase English letter using reverse alphabetical order (, , ..., ).
Return a string formed by concatenating the mapped characters for all words in order.
Example 1:
Input: words = ["abcd","def","xyz"]
weights = [5,3,12,14,1,2,3,2,10,6,6,9,7,8,7,10,8,9,6,9,9,8,3,7,7,2]
Output: "rij"
Explanation: - The weight of "abcd" is . The result modulo 26 is , which maps to 'r'.
- The weight of
"def"is . The result modulo 26 is , which maps to'i'. - The weight of
"xyz"is . The result modulo 26 is , which maps to'j'. Thus, the string formed by concatenating the mapped characters is"rij".
Video Explanation
