Code Room
CodingHardcod-g796
Subject BacktrackingLevel Mid–Senior~30 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

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.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.