← 返回 coinbase 的题目列表Banking System with Advanced Features
类型:online_judge
Implement a banking system with the following features:
CreateAccount(timestamp, accountId): Create a new account.
Deposit(timestamp, accountId, amount): Deposit a specified amount into an account at a given time.
Transfer(timestamp, fromAccountId, toAccountId, amount): Transfer an amount from one account to another at a specified time.
a. Implement TopSpenders(timestamp, n) -> []string: Return the top n users with the highest cumulative spending at the specified time, formatted as "accountId1(spendAmount)", "accountId2(spendAmount2)".
b. Implement SchedulePayment(timestamp, accountId, amount, delay) -> paymentId: Schedule a payment to be deducted in the future and return a payment ID. Implement CancelPayment(timestamp, accountId, paymentId) -> result: Cancel an existing payment, returning nil if it doesn't exist.
c. Implement GetBalance(timestamp, accountId, timeAt) -> balance: Return the historical balance of an account at a specified time. Implement MergeAccount(timestamp, accountId1, accountId2): Merge accountId2 into accountId1 and combine historical balances.
All operations and changes should be traceable and storable at any given point in time.
Example
Input
1
10
100