FastPrepWorkspace Credit Ledger
Problems/Workspace Credit Ledger

Workspace Credit Ledger

Airbnb logoAirbnb● HardFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The original report names the ledger operations, which build on each other. It leaves out the exact results, the ranking, the edge for rebates, and the rules for merge history. We follow one common set of fixed rules for the state machine.

Our version is about 82% the same as the reported question.

You keep a credit ledger for workspaces. You get a list of operations, each with a timestamp. Run them in order and return one string result for each operation.

The ledger starts empty. Timestamps are whole numbers of milliseconds, and they never go down. Operations with the same timestamp run in the order they appear in the input.

Some operations schedule a rebate, which pays credits back later. Before you run each operation from the input at timestamp t, first post every rebate that is due at or before t. Post due rebates in the order their transactions were created.

Operations

  • ["CREATE_WORKSPACE", t, workspaceId]: create an active workspace with a balance of zero and an activity of zero. Return true. Return false if a workspace with that ID is already active.
  • ["ADD_CREDITS", t, workspaceId, amount]: add amount credits, a positive integer, to the workspace. Return its new balance. If the workspace is absent, return the empty string.
  • ["TRANSFER_CREDITS", t, sourceId, targetId, amount]: move amount credits from sourceId to targetId. Both must be active, and they must be two different workspaces. On success, return the source's new balance and add amount to the source's activity. Return the empty string if either workspace is absent, the two IDs are equal, or the source does not have enough credits.
  • ["TOP_WORKSPACES", t, n]: return at most n active workspaces, joined by commas. Write each one as workspaceId(activity). Put the highest activity first. Break ties by workspace ID in ascending order. A workspace's activity is the total of the credits it has successfully sent plus the credits it has successfully consumed.
  • ["CONSUME_CREDITS", t, workspaceId, amount]: take amount credits, a positive integer, from the workspace. Return the empty string if the workspace is absent or does not have enough credits. On success, return the next transaction ID, transactionK. Here K is one counter shared by all workspaces. It starts at one and goes up by one for each successful consumption, so failed consumptions use up no ID. A successful consumption also adds amount to the workspace's activity. It also schedules a rebate of floor(amount * 2 / 100) credits (two percent, rounded down). The rebate is due exactly 86,400,000 milliseconds later, which is one day.
  • ["GET_REBATE_STATUS", t, transactionId]: return PENDING if that transaction's rebate has not posted yet, and RECEIVED once it has. Return the empty string if there is no transaction with that ID.
  • ["MERGE_WORKSPACES", t, survivorId, absorbedId]: merge the absorbed workspace into survivorId. Both must be active, and they must be two different workspaces. Return true on success and false otherwise. The survivor gets the absorbed workspace's current balance and activity. The absorbed workspace's transactions and pending rebates now belong to the survivor. The absorbed workspace becomes inactive.
  • ["GET_BALANCE", t, workspaceId, timeAt]: if workspaceId is active at timestamp t, return its latest balance at or before timeAt. Otherwise, return the empty string. Also return the empty string if timeAt is before the workspace was created. After a merge, the survivor keeps its own balance history from before the merge. Its combined balance starts at the merge timestamp.

If an operation that changes the ledger fails, the ledger stays exactly as it was. Return every number as a decimal string.

Function

processWorkspaceCreditOperations(operations: String[][]) → String[]

Examples

Example 1

operations = [["CREATE_WORKSPACE","1","alpha"],["CREATE_WORKSPACE","2","beta"],["ADD_CREDITS","3","alpha","1000"],["TRANSFER_CREDITS","4","alpha","beta","250"],["TOP_WORKSPACES","5","2"]]return = ["true","true","1000","750","alpha(250),beta(0)"]

The transfer leaves alpha with 750 credits and records 250 activity for the sender. Receiving credits does not increase beta's activity.

Example 2

operations = [["CREATE_WORKSPACE","0","a"],["ADD_CREDITS","1","a","1000"],["CONSUME_CREDITS","10","a","250"],["GET_REBATE_STATUS","86400009","transaction1"],["GET_REBATE_STATUS","86400010","transaction1"],["GET_BALANCE","86400010","a","86400010"]]return = ["true","1000","transaction1","PENDING","RECEIVED","755"]

Consuming 250 credits leaves 750 and schedules a rebate of 5. One millisecond before the due time, the rebate is still pending. At the due time, the rebate posts before that operation runs, so the status is received and the balance query already includes the rebate.

Example 3

operations = [["CREATE_WORKSPACE","1","x"],["CREATE_WORKSPACE","2","y"],["ADD_CREDITS","3","x","100"],["ADD_CREDITS","4","y","200"],["CONSUME_CREDITS","5","y","50"],["MERGE_WORKSPACES","6","x","y"],["GET_BALANCE","7","x","4"],["GET_BALANCE","8","x","6"],["GET_REBATE_STATUS","86400005","transaction1"],["GET_BALANCE","86400005","x","86400005"],["GET_BALANCE","86400006","y","5"]]return = ["true","true","100","200","transaction1","true","100","250","RECEIVED","251",""]

Before the merge, at timestamp 4, x has its own balance of 100. The merge records the combined balance 250 at timestamp 6. The pending rebate from y moves to the survivor and raises x's balance to 251. y is now inactive, so querying it returns the empty string.

Constraints

  • 1 <= operations.length <= 2000.
  • Every timestamp is a nonnegative integer that fits in a signed 64-bit integer. Timestamps never go down. Every rebate due time also fits in a signed 64-bit integer.
  • Every operation has one of the valid shapes listed above.
  • Workspace IDs are non-empty strings of printable ASCII characters. They contain no commas or parentheses.
  • Every credit amount is a positive integer. All balances and activity totals fit in signed 64-bit integers.
  • 1 <= n <= 10^5 for TOP_WORKSPACES.
  • 0 <= timeAt <= t for GET_BALANCE.

More Airbnb Online Assessment questions

  • Bouncing DiagonalsOA · Seen Dec 2026
  • Count Numbers Not Equal to the First TwoOA · Seen Dec 2026
  • Garden Sprinkler PlacementOA · Seen Dec 2026
  • Theme Park Shuttle Wait TimeOA · Seen Dec 2026
  • Count Card Duel RoundsOA · Seen Nov 2026
  • Count Lamps Lighting Each PointOA · Seen Nov 2026
  • Simulate Orchard Rot SpreadOA · Seen Nov 2026
  • Sort Adjacent PairsOA · Seen Nov 2026
  • In-Memory File SystemOA · Seen Nov 2026
  • Task Management SystemOA · Seen Nov 2026

Similar questions at other companies

  • Cloud Compute Credits SystemCoinbase · OACoinbase interview questions
  • Document Enrichment Stream AggregatorBloomberg LP · PHONE SCREENBloomberg LP interview questions
  • Power Cell BankOptiver · OAOptiver interview questions
  • Four-Level Banking System with Scheduled PaymentsZipRecruiter · OAZipRecruiter interview questions
  • Weighted LFU CacheIMC Trading · OAIMC Trading interview questions
  • Weighted LFU CacheMicrosoft · OAMicrosoft interview questions
  • Task Management SystemAnthropic · OAAnthropic interview questions
  • Progressive Parcel Tracking OperationsKlaviyo · OAKlaviyo interview questions
  • Versioned Recipe SystemThe Trade Desk · OA
  • Recipe Management SystemRamp · OARamp interview questions

Interview reports that mention this question

  • Airbnb SWE CodeSignal OA: 19 Experiences

Airbnb interview experiences

  • Airbnb OA · November 2026
  • Airbnb Campus and Full-Time SWE OA / Interviews: 9 Experiences
  • Airbnb Intern Phone Interviews: 21 Experiences (Part 7 of 7)
  • Airbnb Intern OA and Phone Screens: 17 Experiences (Part 6 of 7)
  • Airbnb Intern OA and Onsite Rounds: 16 Experiences (Part 5 of 7)
All Airbnb interview questionsSee Airbnb hiring insights
Saved
class Solution {
    public String[] processWorkspaceCreditOperations(String[][] operations) {
        // Write your code here.
    }
}
Checking account…