Problem · Hash Table
Worker Management, Part 4: Double-Paid Intervals
Learn this problemProblem statement
Continue the worker management system from Part 3. Existing worker, session, promotion, ranking, and salary operations keep their behavior.
Double-Paid Time
["SET_DOUBLE_PAID", start_timestamp, end_timestamp]: register the half-open interval[start_timestamp, end_timestamp)as double-paid time and return an empty string.- Double-paid intervals apply globally to every worker.
- Merge overlapping intervals. Time covered by multiple registered intervals is still paid at most twice, never three or more times.
CALC_SALARYfirst pays normal compensation for completed-session time, then adds one extra copy of compensation for the portion inside double-paid intervals.
Function
workerManagementLevel4(operations: String[][]) → String[]Examples
Example 1
operations = [["ADD_WORKER","Alice","Engineer","100"],["REGISTER","Alice","10"],["REGISTER","Alice","30"],["SET_DOUBLE_PAID","15","25"],["CALC_SALARY","Alice","0","40"],["SET_DOUBLE_PAID","20","35"],["CALC_SALARY","Alice","0","40"]]return = ["true","registered","registered","","3000","","3500"]Alice's completed session pays 20*100 = 2000 normally. The first double-paid interval overlaps it for 10 units, producing 3000. After merging [15,25) with [20,35), the session has 15 double-paid units, producing 3500.
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