This commit is contained in:
parent
308dfbad7e
commit
1fe0c770f9
1 changed files with 11 additions and 0 deletions
11
easy/weighted_word_maaping.py
Normal file
11
easy/weighted_word_maaping.py
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# https://leetcode.com/problems/weighted-word-mapping
|
||||
|
||||
class Solution:
|
||||
def mapWordWeights(self, words: List[str], weights: List[int]) -> str:
|
||||
result = []
|
||||
for word in words:
|
||||
weight = 0
|
||||
for c in word:
|
||||
weight += weights[ord(c) - ord('a')]
|
||||
result.append(chr(ord('z') - weight % 26))
|
||||
return ''.join(result)
|
||||
Loading…
Add table
Add a link
Reference in a new issue