Reported July 2026
Airbnbsimulation

Worker Management with Full-Shift Double Pay

Reported by candidates from Airbnb's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Airbnb OA. Under 2s to a working solution.
Founder's read

The mistake that sinks a first attempt on this Airbnb worker management OA, reported in July 2026, is paying double for any session that merely touches a grant. It's a stateful simulation: add workers, toggle sessions, queue promotions, then compute salary against a union of double-pay intervals. The catch is the all-or-nothing rule. A session only earns double if the whole thing sits inside the merged grants. If you're taking this in the next day or two, read the rules twice. StealthCoder is the safety net running invisibly during the live OA if you blank on the interval logic.

The problem

Process a finite ordered batch of operations for a worker management system. Return one string result for every operation, in encounter order.
Workers and Office Sessions
["ADD_WORKER", worker_id, position, compensation]: add a worker with an hourly compensation. Return true, or false if the ID already exists.
["REGISTER", worker_id, timestamp]: toggle the worker's office state. When outside, start a session; when inside, finish the open session. Return registered, or invalid_request if the worker does not exist.
["GET", worker_id]: return the worker's total time across completed sessions. An open session contributes nothing. Return an empty string for a missing worker.
["TOP_N_WORKERS", n, position]: consider workers whose current position equals position. Rank them by completed time accrued in that position, descending, then by worker ID in ascending lexicographic order. Return up to n entries formatted as workerId(time) and separated by,. Include workers with zero time, and return an empty string when none match.
Promotions and Salary
["PROMOTE", worker_id, new_position, new_compensation, start_timestamp]: queue one pending promotion. Return success, or invalid_request if the worker is missing or already has an unapplied promotion.
A pending promotion activates when that worker next enters at a timestamp greater than or equal to start_timestamp. The position and compensation active at session entry remain attached to that entire session.
["CALC_SALARY", worker_id, start_timestamp, end_timestamp]: return gross salary earned during the half-open query interval [start_timestamp, end_timestamp). Only completed sessions contribute. Return an empty string for a missing worker.
Full-Shift Double Pay
["SET_DOUBLE_PAID", start_timestamp, end_timestamp]: add the global half-open grant interval [start_timestamp, end_timestamp) and return an empty string.
All grant intervals registered before a salary query form one union. Overlapping and adjacent intervals combine, and grants never stack beyond double pay.
A completed session qualifies for double pay only when its entire half-open interval is contained in that union. A partially covered session is paid entirely at its normal rate.
Within the salary query interval, qualifying sessions contribute 2 * overlap_length * session_compensation; other sessions contribute overlap_length * session_compensation. Eligibility is based on the whole original session, even when the query includes only part of it.

Function
workerManagementFullShiftGrants(operations: String[][]) → String[]

Examples
Example 1
operations = [["ADD_WORKER","Alice","Engineer","100"],["REGISTER","Alice","10"],["REGISTER","Alice","30"],["SET_DOUBLE_PAID","10","20"],["SET_DOUBLE_PAID","20","30"],["CALC_SALARY","Alice","0","40"],["REGISTER","Alice","40"],["REGISTER","Alice","60"],["SET_DOUBLE_PAID","45","55"],["CALC_SALARY","Alice","0","70"]]
return = ["true","registered","registered","","","4000","registered","registered","","6000"]
The adjacent grants [10,20) and [20,30) form a union that contains Alice's full session [10,30), so that session earns 20 * 100 * 2 = 4000. The later grant [45,55) covers only part of [40,60), so that second session earns its normal 20 * 100 = 2000. The final gross salary is 6000.
Example 2
operations = [["ADD_WORKER","Bob","Developer","100"],["REGISTER","Bob","5"],["REGISTER","Bob","15"],["PROMOTE","Bob","Senior Developer","200","20"],["REGISTER","Bob","18"],["REGISTER","Bob","22"],["REGISTER","Bob","25"],["REGISTER","Bob","35"],["GET","Bob"],["TOP_N_WORKERS","5","Senior Developer"],["SET_DOUBLE_PAID","25","35"],["CALC_SALARY","Bob","0","40"],["CALC_SALARY","Bob","28","32"]]
return = ["true","registered","registered","success","registered","registered","registered","registered","24","Bob(10)","","5400","1600"]
Bob enters at 18 before the promotion start, so [18,22) keeps the old position and compensation. The promotion activates on the entry at 25. The completed durations total 24, while 10 units belong to the current senior position. Session [25,35) is fully granted and earns 4000; the earlier sessions earn 1400, for gross salary 5400. Query [28,32) overlaps four units of the same qualifying full session and returns 1600.

Constraints
1 <= operations.length <= 2000.
Every operation has a valid name and arity, and every numeric field is a base-10 integer string.
Worker IDs and positions are non-empty strings of at most 50 characters.
1 <= compensation <= 10^6.
0 <= timestamp <= 10^9; all REGISTER timestamps are globally strictly increasing.
Every SET_DOUBLE_PAID and CALC_SALARY interval has start_timestamp < end_timestamp.
1 <= n <= 2000 for every TOP_N_WORKERS operation.
Every salary result fits in a signed 64-bit integer.

Reported by candidates. Source: FastPrep

Pattern and pitfall

Store each worker as a record: position, compensation, open session start, a list of completed sessions, and one pending promotion. Each session snapshots position and compensation at entry. On REGISTER entry, apply the pending promotion if the entry timestamp is >= its start, then clear it. For salary, merge all grant intervals into a sorted union, treating adjacent ones as one (end == next start). For each completed session, check whether its full original [s,e) fits inside a single merged interval. Then multiply the overlap with the query window by compensation, doubled if it qualifies. The pitfalls: checking eligibility against the clipped overlap instead of the whole session, forgetting adjacent merges like [10,20) plus [20,30), and counting open sessions. TOP_N needs sort by time descending, then ID ascending, using time accrued in the current position. StealthCoder is your hedge in the live OA if the merge or promotion timing goes sideways.

The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.

If this hits your live OA

You can drill Worker Management with Full-Shift Double Pay cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Airbnb's OA.

Airbnb reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Worker Management with Full-Shift Double Pay FAQ

What's the trick in the Airbnb worker management OA?+

Eligibility for double pay is decided on the whole original session, not the part inside the query window. Merge grants into a union first, check containment of the full session, then clip to the query window for the overlap length.

How do adjacent grant intervals work?+

They combine. [10,20) and [20,30) become [10,30), so a session spanning 10 to 30 qualifies. Sort the grants, then merge when the next start is less than or equal to the current end. Grants never stack beyond double.

When does a promotion take effect?+

Only when the worker next enters at a timestamp greater than or equal to the promotion's start. A session keeps the position and compensation from its entry for its whole length. Entering before the start keeps the old values, as Bob's entry at 18 shows.

How do I rank TOP_N_WORKERS correctly?+

Filter to workers whose current position matches, then sort by completed time in that position descending, then worker ID ascending. Include zero-time workers. Format as workerId(time) joined by commas, and return an empty string if nobody matches.

How do I prepare for this in 48 hours?+

Write the data model first, then code each operation separately. Hand-run both examples, especially the 4000 and 6000 totals. Test edge cases: open sessions, missing workers, partial grant coverage, and a promotion queued twice returning invalid_request.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Airbnb.

OA at Airbnb?
Invisible during screen share
Get it