Reported January 2026
Rampdesign

Worker Management, Part 2: Top Workers

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

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

The Ramp OA reported in January 2026 is a worker-hours register, and the whole thing hinges on one hash map of worker records plus a sort at query time. Part 2 is "Top Workers": add workers, toggle office sessions with REGISTER, then answer TOP_N_WORKERS by position. It's cumulative, so Level 1 has to be clean before Level 2 means anything. Nothing here is algorithmically hard. It's a state-tracking exercise with picky output formatting, and that's where people lose points. If you blank on the structure during the live OA, StealthCoder is the safety net running invisibly on your screen.

The problem

The source assessment is a cumulative four-level worker-hours register for contract workers at a facility. Each level includes every operation from the earlier levels. This page implements Levels 1 through 2 and returns one string result for every query in input order.
Level 1: Workers and Office Sessions
["ADD_WORKER", workerId, position, compensation] adds a new worker and stores the worker's position and compensation. If workerId already exists, leave the system unchanged and return false; otherwise return true. Worker IDs and positions contain only English letters and spaces.
["REGISTER", workerId, timestamp] records an office entry when the worker is outside and records an exit when the worker is inside. Calls to REGISTER arrive in increasing timestamp order. Return invalid_request for an unknown worker and registered after a successful entry or exit.
["GET", workerId] returns the worker's total time in the office using completed sessions only. A current session without an exit contributes nothing. Return the empty string when the worker does not exist.
Level 2: Ordered Worker Statistics
["TOP_N_WORKERS", n, position] returns at most n workers whose current position equals position.
Order workers by completed office time in descending order. Break equal-time ties by worker ID in ascending alphabetical order.
Format the result as workerId1(time1), workerId2(time2),.... Return every matching worker when fewer than n exist, and return the empty string when there are no matches.
A worker with no completed office session has time 0.
FastPrep Runner Interface
The source uses an array of query rows and one string output per query. FastPrep exposes the same operation rows as workerManagementLevel2(String[][] operations) and returns String[]. Numeric arguments are encoded as base-10 strings.
Multipart Series
Part 1: Office Registration
Part 2: Top Workers
Part 3: Promotions and Salary
Part 4: Double-Paid Intervals

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.

Constraints
1 <= operations.length <= 500, matching the source's query-count bound.
Every row uses an operation available at this level, has the documented arity, and satisfies the source-stated operation preconditions.
Every numeric argument is a valid base-10 integer string.
Worker IDs and positions contain only English letters and spaces.
All REGISTER calls are supplied in increasing timestamp order.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is the data model. Keep a hash map from workerId to a record: position, compensation, total completed time, and the open entry timestamp (or null if outside). REGISTER flips state. If outside, store the timestamp and return registered. If inside, add (timestamp - entry) to total, clear the entry, and return registered. Unknown worker returns invalid_request. GET counts completed sessions only, so an open session adds nothing. For TOP_N_WORKERS, filter workers by exact position match, sort by time descending then ID ascending, take n, and format as id(time) joined with a comma and a space. With at most 500 operations, sorting per query is fine, no heap needed. Pitfalls: counting open sessions, forgetting that duplicate ADD_WORKER returns false, comparing IDs case-insensitively, and returning the empty string instead of null for no matches. StealthCoder is your hedge in the live OA if the formatting trips you up.

If this hits your live OA and you blank, StealthCoder solves it in seconds, invisible to the proctor.

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. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it.

Get StealthCoder

Related leaked OAs

⏵ The honest play

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

Ramp reuses patterns across OAs. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Worker Management, Part 2: Top Workers FAQ

How hard is the Ramp Worker Management Part 2 question really?+

Easy to medium. The logic is a hash map plus a custom sort. The difficulty is the cumulative spec and exact output strings. If you track state carefully and format as id(time) separated by comma and space, you're fine.

What's the trick to TOP_N_WORKERS?+

Filter by exact position, then sort by completed time descending and worker ID ascending as the tiebreak. Take the first n. With 500 operations max, sorting on every query is cheap, so skip heaps and keep it simple.

Does an unfinished office session count toward time?+

No. Only completed sessions count. If a worker has entered but not exited, that session adds nothing to GET or to the ranking. A worker with no completed session shows as time 0 and still appears in results.

What should REGISTER return in edge cases?+

Return registered after any successful entry or exit, and invalid_request if the worker ID doesn't exist. The same call toggles state: outside becomes inside, inside becomes outside and adds the session length to the total.

How do I prepare in 48 hours for this kind of OA?+

Practice stateful simulation problems where you build a class-like system from a list of string commands. Write the Level 1 structure cleanly first, since later levels extend it. Test your output formatting against the example, including the empty-string cases.

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

OA at Ramp?
Invisible during screen share
Get it