Reported July 2026
Airbnbsimulation

Worker Management, Part 2: Top Workers

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

Airbnb's Worker Management Part 2, reported July 2026, looks like a simple extension and then bites you on one detail: ties. If you've seen Part 1, you already have ADD_WORKER, REGISTER and GET. The new TOP_N_WORKERS call is a sort with a compound key, filtered by current position. It's a design-style simulation problem more than an algorithm one. The risk is small mistakes in session pairing and ranking order, not hard theory. If you blank on the details, StealthCoder runs invisibly during the live OA as a safety net. Still, the logic here is short enough to hold in your head.

The problem

Continue the worker management system from Part 1. ADD_WORKER, REGISTER, and GET keep the same behavior.
New Operation
["TOP_N_WORKERS", n, position]: return up to n workers whose current position equals position.
Rank by total time from completed office sessions in descending order, then by worker ID in ascending alphabetical order.
Format the result as workerId1(time1), workerId2(time2),....
A worker with no completed session has time 0. Return an empty string when no worker has the requested position.

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

Examples
Example 1
operations = [["ADD_WORKER","John","Junior Developer","120"],["ADD_WORKER","Jason","Junior Developer","120"],["ADD_WORKER","Ashley","Junior Developer","120"],["REGISTER","John","100"],["REGISTER","John","150"],["REGISTER","Jason","200"],["REGISTER","Jason","250"],["REGISTER","Jason","275"],["TOP_N_WORKERS","5","Junior Developer"],["TOP_N_WORKERS","1","Junior Developer"],["REGISTER","Ashley","400"],["REGISTER","Ashley","500"],["REGISTER","Jason","575"],["TOP_N_WORKERS","3","Junior Developer"],["TOP_N_WORKERS","3","Middle Developer"]]
return = ["true","true","true","registered","registered","registered","registered","registered","Jason(50), John(50), Ashley(0)","Jason(50)","registered","registered","registered","Jason(350), Ashley(100), John(50)",""]
Jason and John initially tie at 50, so Jason comes first alphabetically. Jason's session from 275 to 575 later raises his total to 350.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is that REGISTER alternates. The first call for a worker opens a session, the next one closes it, and only closed sessions add time. Store per worker: position, total time, and an open-start timestamp or null. For TOP_N_WORKERS, filter workers by exact position, sort by total descending then ID ascending, take the first n, and format as id(time) joined by comma and space. The pitfall is the edge case in the example: Jason and John both sit at 50, so the alphabetical tie-break decides the order. Another trap is counting a still-open session. Ashley has 0 until she closes one. Also return an empty string when nobody matches, not an empty list. If the live OA throws you off, StealthCoder can cover you, but this is mostly careful state handling.

StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.

If this hits your live OA

You can drill Worker Management, Part 2: Top Workers 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. If you're reading this with an OA window open, you're who this was built for.

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. If you're reading this with an OA window open, you're who this was built for. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Worker Management, Part 2: Top Workers FAQ

How hard is Airbnb's Worker Management Part 2 really?+

Easy to medium. There's no clever algorithm. It's a stateful simulation where you track sessions per worker and sort on a compound key. Most failures come from misreading the REGISTER toggle or botching the tie-break, not from complexity.

What's the trick to the REGISTER operation?+

Treat REGISTER as a toggle. If the worker has no open session, store the timestamp as the start. If one is open, add the difference to total time and clear the start. Only completed sessions count toward ranking, so an open session contributes nothing.

How should I sort the TOP_N_WORKERS results?+

Sort by total time descending, then worker ID ascending using plain string comparison. Filter by current position first, then slice to n. In the example, Jason and John tie at 50 and Jason wins alphabetically. Don't pad the result if fewer than n workers match.

What edge cases should I test before submitting?+

Test n larger than the matching worker count, a position nobody holds, workers with zero completed sessions showing as (0), ties on time, and a worker with an open session at query time. The empty-string return for no matches is easy to forget.

How do I prepare for this in 48 hours?+

Rebuild Part 1 from memory as a small class with a hash map of workers. Then add the ranking query. Write a few operation lists by hand and trace them, including the tie case from the example. Practice output formatting, since the comma-space separator matters.

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