Sign in to track progress, unlock prep layers, and browse your pipeline.Sign in
Design and implement a bank account system
Problem Description
Design and implement a minimal banking service with the following core capabilities:
Account Management
- Account Creation: Create bank accounts, each with a unique identifier and an initial balance.
- Fund Operations: Support deposit and withdrawal operations. Crucially, prevent overdrafts during withdrawals.
Transaction History
- History Maintenance: Maintain a per-account transaction history. Each transaction record must include:
- A timestamp
- Operation type (e.g., deposit, withdrawal, transfer_pending, transfer_in, transfer_out)
- Amount
- Resulting balance after the operation
- History Retrieval: Provide APIs to fetch the full transaction history for an account, as well as the most recent N entries.
Inter-Account Transfers
- Conditional Execution: Implement inter-account transfers that execute only if the recipient explicitly accepts them.
- Transfer Lifecycle: A transfer begins in a PENDING state and does not alter account balances until it is explicitly accepted by the recipient. If a transfer is rejected or expires, it must be canceled.
- Robustness:
- Ensure idempotent handling for accept and reject operations.
- Validate that the sender has sufficient funds at the time of acceptance.
- Guarantee that all operations are safe under concurrent requests.
Technical Requirements
- API Signatures: Expose clear method signatures for core operations (e.g.,
createAccount,deposit,withdraw,createTransfer,acceptTransfer,rejectTransfer,getHistory). - Design Documentation: Describe the chosen data structures.
- Complexity Analysis: Outline the time and space complexity for core operations.
- Edge Case Handling: Discuss how to handle various edge cases, including:
- Duplicate requests
- Invalid account identifiers
- Negative amounts
- Clock and timestamp considerations
AI interview prep
Core dilemma
Ensuring strong transactional consistency and data integrity across multiple accounts and operations, especially under concurrent load and with multi-stage, conditional transfers, while maintaining a robust, auditable history.
Mid-level signals3
Senior signals3
Red flags3
3 tradeoffs and 3 stress tests locked
Interview prep
Unlock the interviewer X-Ray rubric, tradeoff matrix, stress tests, clarifying questions, and key concepts.
Design and implement a bank account system
Problem Description
Design and implement a minimal banking service with the following core capabilities:
Account Management
- Account Creation: Create bank accounts, each with a unique identifier and an initial balance.
- Fund Operations: Support deposit and withdrawal operations. Crucially, prevent overdrafts during withdrawals.
Transaction History
- History Maintenance: Maintain a per-account transaction history. Each transaction record must include:
- A timestamp
- Operation type (e.g., deposit, withdrawal, transfer_pending, transfer_in, transfer_out)
- Amount
- Resulting balance after the operation
- History Retrieval: Provide APIs to fetch the full transaction history for an account, as well as the most recent N entries.
Inter-Account Transfers
- Conditional Execution: Implement inter-account transfers that execute only if the recipient explicitly accepts them.
- Transfer Lifecycle: A transfer begins in a PENDING state and does not alter account balances until it is explicitly accepted by the recipient. If a transfer is rejected or expires, it must be canceled.
- Robustness:
- Ensure idempotent handling for accept and reject operations.
- Validate that the sender has sufficient funds at the time of acceptance.
- Guarantee that all operations are safe under concurrent requests.
Technical Requirements
- API Signatures: Expose clear method signatures for core operations (e.g.,
createAccount,deposit,withdraw,createTransfer,acceptTransfer,rejectTransfer,getHistory). - Design Documentation: Describe the chosen data structures.
- Complexity Analysis: Outline the time and space complexity for core operations.
- Edge Case Handling: Discuss how to handle various edge cases, including:
- Duplicate requests
- Invalid account identifiers
- Negative amounts
- Clock and timestamp considerations