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 Airbnb problems
- Parcel Event TrackingOA · Seen Jul 2026
- Worker Management, Part 3: Promotions and SalaryOA · Seen Jul 2026
- Worker Management, Part 2: Top WorkersOA · Seen Jul 2026
- Nested List Iterator with RemovePHONE SCREEN · Seen Jul 2026
- Worker Management with Full-Shift Double PayOA · Seen Jul 2026
- Most Frequent Reduced DigitOA · Seen Jul 2026
- Rectangle Fit QueriesOA · Seen Jul 2026
- Robot Final DirectionOA · Seen Jul 2026