Code RoomSum sales by category
EasyPrep Room Coding #392

Sum sales by category

CodingAlgorithms & data structuresEntry–Mid~10 min

A shop's daily sales feed stores one line item per row as "category,amount", where amount is an integer that may be negative (a refund). Build the mini pivot the manager sees each evening: a dictionary mapping each category to the sum of its amounts. Example: ["toys,20", "games,15", "toys,5"] gives {"toys": 25, "games": 15}.

Implement
category_totals(rows: list[str]) → dict[str,int]
Examples
in[["toys,20","games,15","toys,5"]]out{"toys":25,"games":15}
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
[["toys,20","games,15","toys,5"]]{"toys":25,"games":15}not run yetsample