Monetary Pay Computation And Event-Time Aggregation
Asked of: Software Engineer
Last updated

What's being tested
These problems test event-time interval aggregation: converting unordered delivery/work events into valid time ranges, splitting ranges across rate windows, and summing monetary pay exactly. Interviewers are probing for clean data manipulation in Python or SQL, robust edge-case handling, and readable business-rule implementation.
Patterns & templates
-
Sweep line over start/end events — sort by timestamp, maintain active count/state, accumulate
duration * rate;O(n log n)time. -
Interval intersection helper —
overlap = max(0, min(end1,end2) - max(start1,start2)); reuse for peak windows, shifts, and deliveries. -
Normalize then compute — parse timestamps, validate
start < end, dedupe IDs/events, sort chronologically before applying pay rules. -
Segment by rate windows — split one delivery across base, peak, bonus, or minimum-pay windows; never apply one multiplier to the whole interval blindly.
-
Per-day aggregation — group by
driver_id,DATE(ts), or local service day; watch midnight crossings and timezone assumptions. -
SQL window functions — use
LAG,LEAD,ROW_NUMBER, andSUM(...) OVER (...)to pair events and detect malformed sequences. -
Money representation — compute in integer cents or
Decimal; avoid binary floating-point drift in final pay totals.
Common pitfalls
Pitfall: Treating delivery duration as
dropoff - pickupwithout checking overlap against active dash time, peak windows, or day boundaries.
Pitfall: Assuming events are ordered and unique; production-style logs often contain duplicates, missing ends, or contradictory state transitions.
Pitfall: Rounding each segment early; accumulate precise cents/decimals first, then round only at the final contractual boundary.
Practice these
The practice cards below cover the canonical variants — solve all of them and time yourself.
Featured in interview prep guides
Practice questions
- Design Real-Time Driver Pay AggregationDoorDash · Software Engineer · Technical Screen · hard
- Calculate Daily Driver PayDoorDash · Software Engineer · Technical Screen · hard
- Compute dasher pay from order event logsDoorDash · Software Engineer · Take-home Project · medium
- Calculate Courier EarningsDoorDash · Software Engineer · Technical Screen · medium
- Compute courier pay and implement load balancingDoorDash · Software Engineer · Onsite · medium
- Implement a gig worker payout calculatorDoorDash · Software Engineer · Onsite · Medium
- Design a resilient dasher payment systemDoorDash · Software Engineer · Technical Screen · hard
- Compute dasher payout from API dataDoorDash · Software Engineer · Onsite · Medium
- Compute dasher pay from deliveriesDoorDash · Software Engineer · Onsite · Medium
- Implement dasher active-time calculatorDoorDash · Software Engineer · Technical Screen · Medium
- Design payment and delivery services for dasher payoutsDoorDash · Software Engineer · Technical Screen · hard
- Compute courier pay with peak-hour rulesDoorDash · Software Engineer · Technical Screen · Medium
Related concepts
- Money-Safe Financial ComputationCoding & Algorithms
- Temporal Event Processing And Interval AlgorithmsCoding & Algorithms
- Stateful Stream Processing And Time SchedulingCoding & Algorithms
- Expense Rules EnginesSystem Design
- Payment Processing And Ledger SystemsSystem Design
- Intervals, Sliding Windows, And Time-Ordered StateCoding & Algorithms