Calculate Retroactive Pay When Salary Changes Are Entered Late

Last updated: November 29, 2026

Quick Overview

Given pay periods with the date each was paid and a history of salary changes that each have an effective date and an entered-on date, compute for every already-paid period what was paid, what is actually owed today, and the total retro adjustment.

Gusto
Coding & Algorithms
Software Engineer
Gusto
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Hard

0

0

0 solved


Given pay periods with the date each was paid and a history of salary changes that each have an effective date and an entered-on date, compute for every already-paid period what was paid, what is actually owed today, and the total retro adjustment.

Employers on Gusto often record a raise weeks after it took effect, or fix a typo in an earlier change, and the next payroll must true up exactly. This hard onsite problem tests bitemporal reasoning (what was known when versus what is true now), proration inside a period and exact arithmetic.

What the Interviewer Expects
  • Separates effective time from knowledge time (bitemporal model)
  • Reconstructs the rate known at each payment date
  • Prorates a period that contains a mid-period change
  • Handles a correction that supersedes an earlier entry with the same effective date
  • Produces both underpayments and overpayments
  • Rounds only at the per-period cent level with exact intermediates
Key Topics to Cover
Bitemporal data
Effective dating
Proration
Exact rational arithmetic
Retro pay
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you make this efficient for thousands of employees and years of history?
  • An overpayment from a prior tax year cannot just be netted; what changes?
  • How would you present this adjustment on a paystub so the employee understands it?
  • How would hourly employees with rate changes differ from salaried ones?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

periods: (start, end, paid_on). changes: (effective_date, annual_salary, entered_on). A full period pays salary / periods_per_year; a period with a change mid-way is prorated by calendar day...

High-Level Design

The core is rate_on(day, as_of): among changes entered by as_of with effective date on or before day, take the latest effective date, and for ties the latest entry (a correction). Compute period...


Submit Your Answer
Markdown supported

Related Questions