Code RoomProduct count per region
MediumPrep Room Coding #409

Product count per region

CodingAlgorithms & data structuresEntry–Mid~13 min

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.

0:00 of about 13 min
InputExpectedGot
[["west,mug,10","west,mug,20","west,tee,5","east,cap,7"]]{"east":1,"west":2}not run yetsample