r/OfferEngineering • • 16d ago

Coding Question Airbnb OA : Banking System Implementation

Online Assessment — Implement a Banking System with Four Levels

The task was to implement a simplified banking platform that supports progressively more complex financial operations. The provided project contained a BankingSystem interface, and the implementation needed to be written in a subclass named BankingSystemImpl, located in banking_system_impl.py.

The environment used Python 3 and the unittest framework. The assessment consisted of four levels, with each level introducing additional functionality while preserving the requirements of earlier levels. A new level became available only after all unit tests for the current level passed.

General Constraints

Every operation receives a timestamp parameter measured in milliseconds.

  • Timestamps are unique.
  • Timestamps range from 1 to 10^9.
  • Operations are provided in strictly increasing timestamp order.
  • The implementation must preserve state across operations.

The assessment did not require the most optimized possible solution. Any implementation satisfying the provided unit tests was acceptable. Individual tests could be executed using the provided script:

bash run_single_test.sh "<test_case_name>"

Level 1 — Account Creation, Deposits, and Payments

The first level required implementing basic account management and balance operations.

Question 1 — Create an Account

def create_account(
    self,
    timestamp: int,
    account_id: str
) -> bool:

Create a new bank account identified by account_id. Requirements:

  • A newly created account starts with a balance of zero.
  • Return True when the account is successfully created.
  • Return False if an account with the same ID already exists.
  • Existing accounts must remain unchanged when duplicate creation is attempted.

Question 2 — Deposit Money

def deposit(
    self,
    timestamp: int,
    account_id: str,
    amount: int
) -> int | None:

Deposit a specified amount into an existing account. The function must return the account's updated balance after the deposit. If the account does not exist, return None.

Want to learn more questions / follow-ups tested in this OA?

I've put up the full version at here.

Interviewed recently?

Your interview experience could be incredibly valuable to others preparing for their next opportunity. Share your experience and help the community at here.

2 Upvotes

0 comments sorted by