Problem · Design
Banking System, Part 1: Accounts and Transfers
Learn this problemProblem statement
Banking System series
- Part 1: Accounts and Transfers
- Part 2: Top Spenders
- Part 3: Scheduled Payments
- Part 4: Merging and Balance History
Implement the first level of a simplified banking system. The system starts with no accounts and processes operations in strictly increasing timestamp order.
Operation Format
Each row in operations contains an operation name followed by its arguments, all represented as strings. Return one row for every operation:
- A scalar result is returned as a one-element row, such as
["true"]or["750"]. - A source-level
Noneresult is returned as["null"].
Level 1 Operations
["CREATE_ACCOUNT", timestamp, account_id]: Create an account with balance0if the ID does not exist. Returntrueon success andfalseif the account already exists.["DEPOSIT", timestamp, account_id, amount]: Addamountto the account. Return its new balance, ornullif the account does not exist.["TRANSFER", timestamp, source_account_id, target_account_id, amount]: Transfer money between two different accounts. Return the source account's new balance on success. Returnnullif either account does not exist, both IDs are equal, or the source has insufficient funds.
Function
bankingSystemLevel1(operations: String[][]) → String[][]Examples
Example 1
operations = [["CREATE_ACCOUNT","1","alice"],["CREATE_ACCOUNT","2","bob"],["DEPOSIT","3","alice","1000"],["TRANSFER","4","alice","bob","250"],["DEPOSIT","5","bob","50"]]return = [["true"],["true"],["1000"],["750"],["300"]]Alice receives 1000, sends 250 to Bob, and keeps 750. Bob then has 250 from the transfer plus the 50 deposit.
Example 2
operations = [["CREATE_ACCOUNT","1","alice"],["CREATE_ACCOUNT","2","alice"],["DEPOSIT","3","missing","100"],["TRANSFER","4","alice","alice","10"],["CREATE_ACCOUNT","5","bob"],["TRANSFER","6","alice","bob","10"],["DEPOSIT","7","alice","100"],["TRANSFER","8","alice","bob","40"]]return = [["true"],["false"],["null"],["null"],["true"],["null"],["100"],["60"]]The duplicate creation, missing-account deposit, same-account transfer, and insufficient-funds transfer fail. After Alice receives 100, the final transfer succeeds and leaves her with 60.
Constraints
1 <= timestamp <= 10^9- All timestamps are unique and operations are provided in strictly increasing timestamp order.
- Amounts are positive integers and all numeric results fit in a signed 64-bit integer.
- Every operation has exactly the arguments shown above.
More Anthropic problems
- Banking System, Part 2: Top SpendersOA · Seen Jul 2026
- Banking System, Part 3: Scheduled PaymentsOA · Seen Jul 2026
- Banking System, Part 4: Merging and Balance HistoryOA · Seen Jul 2026
- Convert Stack Samples to Trace EventsPHONE SCREEN · Seen Jul 2026
- Cloud Storage SystemOA · Seen Jun 2026
- Repair the Bootloader ProgramONSITE INTERVIEW · Seen Jun 2026
- Normalize a DNS Domain NameOA · Seen May 2026
- Worker Management, Part 4: Double-Paid IntervalsOA · Seen May 2026