Reported September 2026
Instacartsimulation

Worker Management with Promotions and Double-Paid Time

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

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

Instacart's September 2026 OA hands you level 4 of a worker management system, and the twist is small but nasty: SET_DOUBLE_PAID registers a global interval, and CALC_SALARY has to pay extra for overlap without ever paying a third time. In the example, Alice's 20-unit session at rate 100 jumps from 2000 to 3000 to 3500 as intervals merge. This is interval merging plus overlap math layered on a stateful simulation. If you blank on the merge logic during the live assessment, StealthCoder runs invisibly on your desktop as a safety net while you keep your head in the problem.

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.

Constraints
1 <= operations.length <= 5000.
Worker identifiers and positions are nonempty strings without the separator used by the operation matrix.
Timestamps are nonnegative integers and office-entry/exit timestamps are strictly increasing globally.
Compensation, timestamps, completed time, and salary fit in signed 64-bit integers.
Every double-paid interval satisfies start < end.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is to keep the double-paid intervals merged at all times. Store them sorted, and on each SET_DOUBLE_PAID, fold in every interval that touches or overlaps the new one. Merging guarantees the extra pay is counted at most once per unit of time, which is exactly the 'never three times' rule. For CALC_SALARY, compute normal pay for each completed session clipped to the query window, then for each session add rate times its overlap with each merged interval. Overlap of [a,b) and [c,d) is max(0, min(b,d) - max(a,c)). The common pitfall is summing overlaps against unmerged intervals, which double-counts. Another is forgetting that only completed sessions count, and that Part 3 behavior (promotions, rates) must stay untouched. With at most 5000 operations, a linear scan per query is fine. If the merge or clipping logic slips mid-assessment, StealthCoder is the hedge that gives you a working solution live.

If you see this problem in your OA tomorrow, the play is to recognize the pattern in 30 seconds. StealthCoder buys you that recognition.

If this hits your live OA

You can drill Worker Management with Promotions and Double-Paid Time 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. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken.

Get StealthCoder

Related leaked OAs

⏵ The honest play

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

Instacart reuses patterns across OAs. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Worker Management with Promotions and Double-Paid Time FAQ

What's the trick in the Instacart double-paid time problem?+

Merge overlapping double-paid intervals on every SET_DOUBLE_PAID so the extra pay can never be counted more than once. Then for each completed session, add rate times the overlap with each merged interval. Normal pay and the bonus are computed separately and summed.

How do I compute overlap on half-open intervals?+

For [a,b) and [c,d), overlap is max(0, min(b,d) - max(a,c)). Half-open means touching endpoints give zero overlap. When merging, decide whether adjacent intervals like [10,20) and [20,30) fuse. It doesn't change the salary math either way.

Does the double-paid time apply to just one worker?+

No. The statement says double-paid intervals apply globally to every worker. Store them in one shared structure, not per worker. Any CALC_SALARY call for any worker uses the full merged set at the time of the query.

Do I need an efficient data structure with 5000 operations?+

Not really. With operations capped at 5000, a sorted list of merged intervals and a linear scan per salary query is enough. Spend your effort on correctness of merging and clipping to the query window, not on segment trees.

How do I prepare for this in 48 hours?+

Practice interval merging and interval overlap clipping until they're automatic. Then write a small simulation harness that replays the example and checks 2000, 3000, then 3500. Re-read how earlier parts handle sessions, since this level must keep their behavior exactly.

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

OA at Instacart?
Invisible during screen share
Get it