Reported July 2026
Anthropicdesign

Worker Management, Part 4: Double-Paid Intervals

Reported by candidates from Anthropic's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Anthropic OA. Under 2s to a working solution.
Founder's read

The whole problem hangs on one structure: a sorted list of merged, non-overlapping intervals. This Anthropic OA, reported in July 2026, is Part 4 of the worker management series, and it adds SET_DOUBLE_PAID on top of sessions, promotions, ranking and salary. Your earlier parts still have to behave exactly the same. The new piece is interval merging plus overlap math inside CALC_SALARY. If you blank on the merge logic with the clock running, StealthCoder is the invisible safety net on the live OA. Here's the pattern so you don't need it.

The problem

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_SALARY first 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.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is to store double-paid time as a merged interval list. On each SET_DOUBLE_PAID, insert the new [s, e), then sort and collapse any intervals that overlap or touch. That guarantees time is never counted a third time. In CALC_SALARY, pay normal rate for the completed session time in the query window, then add the overlap between each completed session and each merged interval, clipped to the query range, times the rate. Overlap of two half-open ranges is max(0, min(e1,e2) - max(s1,s2)). The common pitfall is not merging, which double-counts overlapping registrations and gives 3000 instead of 3500 in the example. Another is forgetting that double-paid applies globally, not per worker, and that rate changes from promotions still apply. If you freeze mid-OA, StealthCoder can hand you the merge and overlap code live.

Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.

If this hits your live OA

You can drill Worker Management, Part 4: Double-Paid Intervals 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 by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Anthropic's OA.

Anthropic reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Worker Management, Part 4: Double-Paid Intervals FAQ

What's the core trick in Worker Management Part 4?+

Keep a merged list of non-overlapping double-paid intervals. Every new SET_DOUBLE_PAID gets inserted and merged with anything it overlaps. Then salary is normal pay plus one extra copy of pay for the overlap between each session and those merged intervals. Merging is what caps the multiplier at two.

How do I compute the overlap with a session?+

For half-open ranges, overlap length is max(0, min(end1, end2) - max(start1, start2)). Clip the session to the CALC_SALARY query window first, then intersect with each merged interval. Multiply the overlap by the worker's rate at that time and add it on top of normal pay.

Why does the example go from 3000 to 3500?+

Alice's session runs 10 to 30, which is 20 units at rate 100, so 2000 base. The first interval [15,25) overlaps 10 units, adding 1000. After merging [15,25) with [20,35) into [15,35), the overlap is 15 units, adding 1500. So 3500.

Do double-paid intervals apply to one worker or everyone?+

Everyone. The intervals are global state, not tied to a worker. Keep one shared list and consult it for every CALC_SALARY call, whichever worker is queried. Don't clear or copy it per worker.

How should I prepare in 48 hours?+

Make sure you can write interval merging and the overlap formula from memory. Then trace the example by hand. Spend the rest of your time making sure your earlier parts still pass, since this level builds on them. Edge cases: touching intervals, empty intervals, and sessions outside the query window.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Anthropic.

OA at Anthropic?
Invisible during screen share
Get it