Code RoomWindow function running sum
MediumPrep Room Coding #330

Window function running sum

CodingDatabases & SQLMid–Senior~25 min

Implement a SQL window function: SUM(amount) OVER (PARTITION BY account ORDER BY ts). Given rows as [account, ts, amount] (ts integers, may arrive out of order), return for each input row, in the ORIGINAL input order, a [account, ts, running_sum] triple where running_sum is the cumulative amount for that account up to and including that row's ts (rows with equal ts within an account are all included). Assume (account, ts) is unique. Up to 5000 rows.

Implement
running_sum_window(rows: list[list]) → list[list]
Examples
in[[["a",1,10],["a",2,5],["a",3,20]]]out[["a",1,10],["a",2,15],["a",3,35]]
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 25 min
InputExpectedGot
[[["a",1,10],["a",2,5],["a",3,20]]][["a",1,10],["a",2,15],["a",3,35]]not run yetsample