Code RoomMaximum word score
HardPrep Room Coding #1359

Maximum word score

CodingAlgorithms & data structuresMid–Senior~30 min

Given a list of `words`, a multiset of available `letters` (lowercase), and a `score` array of length 26 where `score[i]` is the value of letter 'a'+i, choose a subset of words to maximize the total score. A word scores the sum of its letters' scores, but you can only use each available letter once across all chosen words (a word can only be used if you have all its letters remaining). Return the maximum achievable score. 1 <= len(words) <= 14.

Implement
max_score_words(words: list[str], letters: list[str], score: list[int]) → int
Examples
in[["dog","cat","dad","good"],["a","a","c","d","d","d","g","o","o"],[1,0,9,5,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]]out19
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

0:00 of about 30 min
InputExpectedGot
[["dog","cat","dad","good"],["a","a","c","d","d","d","g","o","o"],[1,0,9,5,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]]19not run yetsample