Code RoomWord score
EasyPrep Room Coding #451

Word score

CodingAlgorithms & data structuresEntry–Mid~10 min

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]) → int
Examples
in["cab",{"a":1,"b":3,"c":3}]out7
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 10 min
InputExpectedGot
["cab",{"a":1,"b":3,"c":3}]7not run yetsample