Worker Management, Part 1: Office Registration
Problem statement
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 Level 1 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. IfworkerIdalready exists, leave the system unchanged and returnfalse; otherwise returntrue. 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 toREGISTERarrive in increasing timestamp order. Returninvalid_requestfor an unknown worker andregisteredafter 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.
FastPrep Runner Interface
The source uses an array of query rows and one string output per query. FastPrep exposes the same operation rows as workerManagementLevel1(String[][] operations) and returns String[]. Numeric arguments are encoded as base-10 strings.
Multipart Series
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.
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
REGISTERcalls are supplied in increasing timestamp order.