Code RoomProduct revenue share
MediumPrep Room Coding #415

Product revenue share

CodingAlgorithms & data structuresEntry–Mid~14 min

Marketing wants each product's share of revenue as a whole-number percentage. Each row is "product,amount" with a POSITIVE integer amount; a product may appear on many rows, and there is at least one row. Return a dictionary mapping each product to floor(100 * product_total / grand_total). Shares may not add up to exactly 100 because of flooring — that is expected. Example: ["mug,30", "tee,50", "mug,20"] gives {"mug": 50, "tee": 50}.

Implement
revenue_share(rows: list[str]) → dict[str,int]
Examples
in[["mug,30","tee,50","mug,20"]]out{"mug":50,"tee":50}
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 14 min
InputExpectedGot
[["mug,30","tee,50","mug,20"]]{"mug":50,"tee":50}not run yetsample