Code Room
CodingMediumcod-g1269
Subject HashingLevel Entry–Mid~14 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

A podcast dashboard rolls listener plays up by region. Each play is recorded as a two-letter country code, and a reference table maps country codes to region names. Codes missing from the table are grouped under the literal region "other". Given the list of play country codes and the reference table, return a dictionary mapping each region name that received at least one play to its play count. For example, plays ["us", "de", "us", "xx"] with table {"us": "na", "de": "eu"} give {"na": 2, "eu": 1, "other": 1}. An empty play list returns an empty dictionary.

Implement
plays_by_region(codes: list[str], regions: dict[str,str]) → dict[str,int]
Examples
in[["us","de","us","xx"],{"de":"eu","us":"na"}]out{"eu":1,"na":2,"other":1}
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.