Code Room
CodingEasycod-g1231
Subject Data wranglingLevel Entry–Mid~11 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

A store's sales feed tags each line with a slash-separated catalog path. Each row is "path,amount" where path looks like "electronics/phones/cases" and amount is a positive integer; a path may also be a single segment like "toys". For the executive summary, total the amounts per TOP-LEVEL section (the first path segment). Example: ["electronics/phones,200", "electronics/laptops,300", "home/kitchen,50"] gives {"electronics": 500, "home": 50}.

Implement
top_level_totals(rows: list[str]) → dict[str,int]
Examples
in[["electronics/phones,200","electronics/laptops,300","home/kitchen,50"]]out{"home":50,"electronics":500}
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.