← 返回 coinbase 的题目列表Transaction History System with Add, Delete, and Balance Calculation
类型:online_judge
coinbase
Implement a transaction history system, which requires the following functionalities:
Add transaction records in the format 'Sender -> Receiver, Amount'. Example: 'A -> B, 20'.
Delete a transaction and recalculate the balances for all participants.
Output the final account balances.
Assume the initial account balance for each participant is 0.
Test Case:
Input: Transactions = ['A -> B, 20', 'B -> C, 10', 'C -> D, 5'] Delete = 'B -> C, 10'
Output: {'A': -20, 'B': 10, 'C': -5, 'D': 5}
Example
Input
{'transactions': ['A -> B, 20', 'B -> C, 10', 'C -> D, 5'], 'delete': 'B -> C, 10'}