Software Engineer • Senior-Level
Software Engineer • Senior-Level
High QualityPrep Other Coding Questions Asked by Airbnb
Continue with targeted prep from Airbnb's coding question bank.
Interview Summary
The exercise was organized into four levels, progressively introducing account creation, credit transfers, balance rankings, scheduled transactions, account merging, and historical balance queries.
Interview Details
Online Assessment — Timestamped Credit Account Management System
You are given a sequence of timestamped operations for a system that manages accounts containing credits. Each account has a unique identifier and a balance. The system must process operations in chronological order and return the corresponding result for every operation. As the assessment progresses, the system must support increasingly complex features, including scheduled transfers, account merging, and historical balance queries.
Function Signature
processCreditAccounts(queries: String[][]) -> String[]
Each query contains an operation name, a timestamp, and the arguments required for that operation. Return an array of strings containing one result per input query. For the reconstructed specification:
- Boolean results are represented by
"true"or"false". - Numerical results are returned as decimal strings.
- Unsuccessful operations that normally return a balance or identifier return an empty string.
Part 1 — Account Creation and Basic Credit Operations
Operation 1 — CREATE_ACCOUNT
["CREATE_ACCOUNT", timestamp, accountId]: Create a new credit account with an initial balance of zero.
Requirements
- Each account identifier must be unique.
- Creating an account with an unused identifier succeeds and returns
"true". - Attempting to create an account with an identifier that has already been used returns
"false". - An identifier cannot be reused even if the original account was subsequently deactivated through merging.
Operation 2 — ADD_CREDIT
["ADD_CREDIT", timestamp, accountId, amount]: Add a positive number of credits to an existing active account.
Requirements
- The target account must exist and be active.
- Increase the account balance by the specified amount.
- Return the updated balance as a string.
- Return an empty string if the account does not exist or is inactive.
Operation 3 — TRANSFER
["TRANSFER", timestamp, sourceId, targetId, amount]: Transfer credits from one account to another.
Requirements
- Both accounts must exist and be active.
- The source and destination must be different accounts.
- The source account must contain sufficient credits.
- A successful transfer decreases the source balance and increases the destination balance by the same amount.
- Return the source account's updated balance after a successful transfer.
- Return an empty string if the transfer is invalid or cannot be completed.
Part 2 — Account Ranking by Credit Balance
Operation 4 — TOP_K
["TOP_K", timestamp, k]: Return up to k active accounts ranked by their current credit balances.
Ranking Rules
- Rank accounts by balance in descending order.
- When two accounts have equal balances, rank them by account identifier in ascending lexicographical order.
- Include only currently active accounts.
- Return at most
kaccounts.
Each ranked account is represented as: accountId(balance). Multiple entries are separated by commas without spaces. For example: "alpha(180),beta(125),gamma(90)". If no active accounts exist, return an empty string.
Part 3 — Scheduled Transfers and Cancellation
The next functionality introduces transfers that are scheduled to occur in the future. Unlike immediate transfers, scheduled transfers are not executed when they are created.
Operation 5 — SCHEDULE_TRANSFER
`["SCHEDULE_TRANSFER", timestamp, sourceId,
Unlock Full Details
Create a free account to unlock this interview experience report.