Question
You are given `rows`, a list of dicts each with keys 'region', 'product', and 'amount' (an integer). Build a pivot table: return a list of [region, product, total] triples giving the summed 'amount' for every (region, product) pair that appears. Sort the output ascending by region, then by product. Regions/products are non-empty strings; amounts may be negative.
pivot_totals(rows: list[dict]) → list[list][[{"amount":10,"region":"us","product":"a"},{"amount":5,"region":"us","product":"a"},{"amount":3,"region":"eu","product":"b"}]]out[["eu","b",3],["us","a",15]]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.