Code Room
CodingMediumcod-g1229
Subject Data wranglingLevel Entry–Mid~13 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

A sales team wants product breadth per region, not volume. Each row is "region,product,amount"; the same region-product pair can recur across many sales. Return a dictionary mapping each region to how many DISTINCT products it sold (the amount is irrelevant). Example: ["west,mug,10", "west,mug,20", "west,tee,5", "east,cap,7"] gives {"west": 2, "east": 1}.

Implement
distinct_products(rows: list[str]) → dict[str,int]
Examples
in[["west,mug,10","west,mug,20","west,tee,5","east,cap,7"]]out{"east":1,"west":2}
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.