Reported January 2026
Rampsimulation

Worker Management, Part 4: Double-Paid Intervals

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

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

Ramp reported this one in January 2026, and the title alone tells you it's the last level of a four-part build. It's a worker-hours register with promotions, salary queries, and a double-pay overlay. Most people sail through levels 1 to 3, then get burned at level 4 because overlapping double-paid periods must never stack past 2x. If your OA invite lists a multi-level simulation like this, expect the nasty edge case at the end. StealthCoder sits invisibly on your screen as a safety net if you blank on the interval logic mid-assessment.

The problem

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 Levels 1 through 4 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. If workerId already exists, leave the system unchanged and return false; otherwise return true. 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 to REGISTER arrive in increasing timestamp order. Return invalid_request for an unknown worker and registered after 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.
Level 2: Ordered Worker Statistics
["TOP_N_WORKERS", n, position] returns at most n workers whose current position equals position.
Order workers by completed office time in descending order. Break equal-time ties by worker ID in ascending alphabetical order.
Format the result as workerId1(time1), workerId2(time2),.... Return every matching worker when fewer than n exist, and return the empty string when there are no matches.
A worker with no completed office session has time 0.
Level 3: Promotions and Salary
["PROMOTE", workerId, newPosition, newCompensation, startTimestamp] schedules a new position and compensation. The source guarantees that newPosition differs from the worker's current position and that startTimestamp is greater than the timestamp of the latest REGISTER call for any worker.
A scheduled promotion becomes active on the worker's first office entry whose timestamp is at least startTimestamp. A session beginning earlier keeps the previous position and compensation.
Return invalid_request when the worker does not exist or already has a promotion waiting to take effect. Return success when the promotion is scheduled.
After promotions exist, TOP_N_WORKERS selects workers by current position and ranks them using completed time accumulated in that current position. GET continues to return lifetime completed time across past and current positions.
["CALC_SALARY", workerId, startTimestamp, endTimestamp] returns salary earned between the two timestamps. Only completed office sessions contribute. For each contributing portion of a session, multiply its duration by the compensation attached to that session. Return the empty string for an unknown worker.
Level 4: Double-Paid Periods
["SET_DOUBLE_PAID", startTimestamp, endTimestamp] registers a period during which worked time receives double pay.
Double-paid periods may overlap, but overlapping coverage never stacks beyond a 2× multiplier.
The operation has no worker parameter, so the registered periods apply to every worker. CALC_SALARY pays normal compensation for completed-session time and adds one extra copy of compensation for covered time.
FastPrep representation choices
Salary-query and double-paid periods use half-open intervals [startTimestamp, endTimestamp).
SET_DOUBLE_PAID returns the empty string because the source report preserves its state change but not a scalar return value.
FastPrep Runner Interface
The source uses an array of query rows and one string output per query. FastPrep exposes the same operation rows as workerManagementLevel4(String[][] operations) and returns String[]. Numeric arguments are encoded as base-10 strings.
Multipart Series
Part 1: Office Registration
Part 2: Top Workers
Part 3: Promotions and Salary
Part 4: 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 <= 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 REGISTER calls are supplied in increasing timestamp order.
Each PROMOTE uses a new position different from the worker's current position.
A promotion's startTimestamp is greater than the timestamp of the latest prior REGISTER call for any worker.
Each salary query satisfies endTimestamp > startTimestamp >= 0.
For the FastPrep interval representation, each SET_DOUBLE_PAID query satisfies endTimestamp > startTimestamp >= 0.

Reported by candidates. Source: FastPrep

Pattern and pitfall

This is a design and simulation problem. Store each worker's sessions as records with start, end, and the compensation attached at entry time. A pending promotion activates on the first entry at or above its start timestamp, so it must bind to the session, not to the query time. The level 4 trick: don't add up each double-paid period separately. Merge all periods into a union of disjoint half-open intervals first. Then, for each completed session clipped to the salary window, pay duration times compensation, plus overlap with the merged union times compensation once more. Summing raw periods double-counts overlaps and produces 3x or 4x pay. Also watch the open session, which pays nothing, and the half-open boundaries. If the merge logic goes sideways live, StealthCoder is your hedge in the actual OA.

StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.

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. If you're reading this with an OA window open, you're who this was built for.

Get StealthCoder

Related leaked OAs

⏵ The honest play

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

Ramp reuses patterns across OAs. If you're reading this with an OA window open, you're who this was built for. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Worker Management, Part 4: Double-Paid Intervals FAQ

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

Merge the double-paid periods into disjoint intervals before computing anything. Overlaps cap at a 2x multiplier, so you add exactly one extra copy of compensation for covered time. Then intersect each completed session, clipped to the query window, with the merged intervals and multiply by that session's own compensation.

Why do naive solutions fail on double-paid intervals?+

They add every SET_DOUBLE_PAID period independently. Two overlapping periods then count the shared stretch twice, giving 3x pay instead of 2x. Merging first, or using a sweep over sorted endpoints, fixes it. Also check that you use half-open [start, end) boundaries so adjacent periods don't double-count a timestamp.

How should I handle promotions with salary calculation?+

Attach position and compensation to each session when the worker enters, not when you query. A scheduled promotion activates on the first entry with timestamp at or above its start. Earlier sessions keep old pay. Per-position time for TOP_N_WORKERS should be tracked separately from lifetime time returned by GET.

Does an unfinished session count toward salary or GET?+

No. Only completed sessions contribute to GET, TOP_N_WORKERS, and CALC_SALARY. A worker currently inside the office with no exit yet adds nothing. Make sure your clipping logic skips open sessions entirely instead of treating the query end as an exit.

How do I prepare for a multi-level OA like this in 48 hours?+

Practice structuring state cleanly: a worker map, a session list per worker, and a helper that computes overlap between two intervals. Write the interval merge and overlap helpers from memory. Then run the sample cases by hand, especially tie-break ordering in TOP_N_WORKERS and the empty-string returns for unknown workers.

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

OA at Ramp?
Invisible during screen share
Get it