Return every transaction with the account balance after that transaction. Transactions are ordered by posted_at; when two share a timestamp, the lower txn_id posts first.
balanceaccount_id, then posted_at, then txn_idtransactions| amount | txn_id | posted_at | account_id |
|---|---|---|---|
| 100 | 1 | 2024-01-01 10:00:00 | 500 |
| -30 | 2 | 2024-01-02 10:00:00 | 500 |
| 200 | 3 | 2024-01-03 10:00:00 | 500 |
| txn_id | account_id | posted_at | amount | balance |
|---|---|---|---|---|
| 1 | 500 | 2024-01-01 10:00:00 | 100 | 100 |
| 2 | 500 | 2024-01-02 10:00:00 | -30 | 70 |
| 3 | 500 | 2024-01-03 10:00:00 | 200 | 270 |
transactions| amount | txn_id | posted_at | account_id |
|---|---|---|---|
| 50 | 1 | 2024-01-01 00:00:00 | 1 |
| 70 | 2 | 2024-01-01 00:00:00 | 2 |
| 25 | 3 | 2024-01-02 00:00:00 | 1 |
| txn_id | account_id | posted_at | amount | balance |
|---|---|---|---|---|
| 1 | 1 | 2024-01-01 00:00:00 | 50 | 50 |
| 3 | 1 | 2024-01-02 00:00:00 | 25 | 75 |
| 2 | 2 | 2024-01-01 00:00:00 | 70 | 70 |
Community-reported interview topic. Not an official company question and no affiliation is implied.
Run against the public tests, or submit to score against all of them.