Word score
A word game scores each letter with a point table: a dictionary mapping single-character strings to integer point values. The score of a word is the sum of the point values of its characters, counted once per occurrence; characters missing from the table are worth 0 points. Given the word and the table, return its total score. For example, "cab" with {"a": 1, "b": 3, "c": 3} scores 3 + 1 + 3 = 7, and "dog" with {"d": 2, "g": 3} scores 5 because "o" is unpriced.
Implement
word_score(word: str, points: dict[str,int]) → intExamples
in
["cab",{"a":1,"b":3,"c":3}]out7What 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 10 min
solution.py
InputExpectedGot
["cab",{"a":1,"b":3,"c":3}]7not run yetsample