FastPrepTax Calculation with Year and Filing Rules
Problems/Tax Calculation with Year and Filing Rules

Tax Calculation with Year and Filing Rules

Gusto logoGusto● MediumFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The interview report names a classic tax-calculation task with follow-ups for the year, the filing status, and custom fixed rates. It does not give how brackets are written, which rule wins, or how to round. Our version is about 68% the same as the reported question.

Calculate tax for taxableIncome, expressed in integer cents. Tax rules are supplied in parallel arrays. Rule i applies when ruleYears[i] == year and ruleStatuses[i] equals filingStatus. Exactly one rule matches.

For a matching rule, bracketEnds[i][j] is the exclusive upper income bound of marginal bracket j, and ratesBps[i][j] is its rate in basis points, where 100 basis points equal one percent. Brackets start at 0, are contiguous, and the final end covers taxableIncome. For each bracket, round that bracket's tax down to a whole cent, then sum the bracket taxes.

If customRateBps is nonnegative, it overrides the matching marginal rule. Return floor(taxableIncome * customRateBps / 10000). A value of -1 means no custom rate.

Function

calculateTax(taxableIncome: long, year: int, filingStatus: String, ruleYears: int[], ruleStatuses: String[], bracketEnds: long[][], ratesBps: int[][], customRateBps: int) → long

Examples

Example 1

taxableIncome = 100000year = 2026filingStatus = "single"ruleYears = [2026]ruleStatuses = ["single"]bracketEnds = [[50000,100000]]ratesBps = [[1000,2000]]customRateBps = -1return = 15000

The first 50000 cents are taxed at 10% for 5000 cents, and the next 50000 at 20% for 10000 cents.

Example 2

taxableIncome = 100000year = 2026filingStatus = "single"ruleYears = [2026]ruleStatuses = ["single"]bracketEnds = [[50000,100000]]ratesBps = [[1000,2000]]customRateBps = 1500return = 15000

The custom 15% rate overrides the marginal brackets.

Example 3

taxableIncome = 60000year = 2025filingStatus = "joint"ruleYears = [2025,2025]ruleStatuses = ["single","joint"]bracketEnds = [[30000,100000],[40000,100000]]ratesBps = [[1000,2000],[500,1000]]customRateBps = -1return = 4000

The joint rule applies: 40000 cents at 5% plus 20000 cents at 10%.

Constraints

  • 0 <= taxableIncome <= 10^12.
  • 1 <= ruleYears.length == ruleStatuses.length == bracketEnds.length == ratesBps.length <= 1000.
  • Exactly one rule matches year and filingStatus.
  • Each rule has 1 to 50 strictly increasing positive bracket ends, and its final end is at least taxableIncome.
  • Each rate is between 0 and 10000 basis points.
  • customRateBps == -1 or 0 <= customRateBps <= 10000.

More Gusto Onsite Interview questions

  • Fair Capped Money DistributionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Response Time Stats by URL PatternONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Sustained Overspeed AlertsFleetx · ONSITE INTERVIEW
  • Spiral MatrixAthenahealth · ONSITE INTERVIEW
  • Query Log MatchDatadog · PHONE SCREEN · ONSITE INTERVIEWDatadog interview questions
  • Random Dasher Set OperationsDoorDash · ONSITE INTERVIEWDoorDash interview questions
  • Propagating Fraud DetectorAffirm · PHONE SCREEN · ONSITE INTERVIEWAffirm interview questions
  • Deep Copy a Random-Pointer ListAmazon · ONSITE INTERVIEW
  • Digit-Coded Card ValidationCapital One · ONSITE INTERVIEWCapital One interview questions
  • Instant-Runoff Voting WinnerWise · ONSITE INTERVIEW
  • Candy Crush Grid Matching and GravityRoblox · PHONE SCREEN · ONSITE INTERVIEWRoblox interview questions
  • Online Meeting Scheduler with Fixed RoomsUber · ONSITE INTERVIEWUber interview questions
All Gusto interview questionsSee Gusto hiring insights
Saved
class Solution {
    public long calculateTax(long taxableIncome, int year, String filingStatus, int[] ruleYears, String[] ruleStatuses, long[][] bracketEnds, int[][] ratesBps, int customRateBps) {
      // Write your code here.
    }
}
Checking account…