Problem · Hash Table
Worker Management, Part 1: Office Registration
Learn this problemProblem statement
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. Returntrueon success orfalseif the ID already exists.["REGISTER", worker_id, timestamp]: toggle the worker's office state. When outside, record an entry; when inside, close the session. Returnregistered, orinvalid_requestif 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.
More Anthropic problems
- Banking System, Part 1: Accounts and TransfersOA · Seen Jul 2026
- Banking System, Part 2: Top SpendersOA · Seen Jul 2026
- Banking System, Part 3: Scheduled PaymentsOA · Seen Jul 2026
- Banking System, Part 4: Merging and Balance HistoryOA · Seen Jul 2026
- Convert Stack Samples to Trace EventsPHONE SCREEN · Seen Jul 2026
- Cloud Storage SystemOA · Seen Jun 2026
- Repair the Bootloader ProgramONSITE INTERVIEW · Seen Jun 2026
- Normalize a DNS Domain NameOA · Seen May 2026