Window function running sum

Write codeMedium25 minSnowflake and Databricks style

Your task

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.

Examples

running_sum_window(rows: list[list]) -> list[list]
Example 1
Inputrunning_sum_window([["a", 1, 10], ["a", 2, 5], ["a", 3, 20]])
Output[["a", 1, 10], ["a", 2, 15], ["a", 3, 35]]