Worker Management, Part 1: Office Registration
Reported by candidates from Anthropic's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The mistake that sinks a first attempt on this Anthropic OA, reported in July 2026, is counting the unfinished visit. Worker Management Part 1 looks like a plain hash map exercise, and it mostly is. You process ADD_WORKER, REGISTER and GET in order and return one string per operation. The trap is in the toggle logic and the edge cases around it. If you've got an invite for this one, expect later parts to build on your level 1 code, so a clean structure matters. StealthCoder sits invisibly on your screen as a safety net if you blank mid-assessment.
The problem
Build the first level of a worker management system. Process each operation in order and return one string result per operation. Operations ["ADD_WORKER", worker_id, position, compensation]: add a worker and save the position and hourly compensation. Return true on success or false if the ID already exists. ["REGISTER", worker_id, timestamp]: toggle the worker's office state. When outside, record an entry; when inside, close the session. Return registered, or invalid_request if the worker does not exist. REGISTER timestamps are strictly increasing. ["GET", worker_id]: return the total time from completed office sessions. An unfinished visit contributes zero. Return an empty string for a missing worker. Worker IDs and positions contain only English letters and spaces. Function workerManagementLevel1(operations: String[][]) → String[] Examples Example 1 operations = [["ADD_WORKER","Ashley","Middle Developer","150"],["ADD_WORKER","Ashley","Junior Developer","100"],["REGISTER","Ashley","10"],["REGISTER","Ashley","25"],["GET","Ashley"],["REGISTER","Ashley","40"],["REGISTER","Ashley","67"],["REGISTER","Ashley","100"],["GET","Ashley"],["GET","Walter"],["REGISTER","Walter","120"]] return = ["true","false","registered","registered","15","registered","registered","registered","42","","invalid_request"] Ashley's completed sessions are [10,25) and [40,67), totaling 42. The entry at 100 is unfinished and does not count.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The pattern is design plus a hash table. Keep a map from worker_id to a small record: position, compensation, total completed time, and the open entry timestamp (or null). REGISTER flips state. If there's no open entry, store the timestamp and return registered. If there is one, add timestamp minus entry to the total, clear the entry, and return registered. GET returns the total as a string, or an empty string for a missing worker. The pitfall is adding time on entry, or adding the unfinished visit in GET. Example 1 shows it: Ashley's open entry at 100 contributes zero, so the answer is 15 + 27 = 42. Also remember every result is a string, including
Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.
You can drill Worker Management, Part 1: Office Registration 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. Made for the candidate who got the OA invite this morning and has 72 hours, not six months.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Anthropic's OA.
Anthropic reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Worker Management, Part 1: Office Registration FAQ
What's the trick in Worker Management Part 1?+
Store an open-entry timestamp per worker and toggle it on each REGISTER. Only add elapsed time when you close a session. GET returns the sum of closed sessions, so an open visit adds nothing. Everything else is hash map lookups and string conversion.
What does a duplicate ADD_WORKER do?+
It returns false and changes nothing. Don't overwrite the existing position or compensation. In the example, the second Ashley add with Junior Developer and 100 is rejected, and her original record stays intact.
What should GET return for a worker who is currently inside?+
Only the sum of completed sessions. If Ashley entered at 100 and never left, that visit counts as zero. Her GET still returns 42 from the two closed sessions. Return an empty string only when the worker doesn't exist.
Why is it called Part 1, and does that change how I code it?+
The title says first level, so later parts likely extend this system. Keep worker data in a clean record or class instead of scattered maps. I can't tell you what later levels ask, but tidy structure makes extensions cheap.
How do I prepare for this in 48 hours?+
Write it once from scratch against the example and check you get all eleven outputs. Then test edge cases: REGISTER on a missing worker, GET on a missing worker, a worker with one open session, and duplicate adds. It's a small problem, so accuracy beats speed.