Compute Progressive Tax Owed With Exact Bracket Arithmetic

Last updated: November 29, 2026

Quick Overview

Given taxable income in cents and an ordered list of brackets (upper bound or none, and rate), return the tax owed, the effective rate and the marginal rate, using exact arithmetic so results never drift by a cent.

PwC
Coding & Algorithms
Software Engineer
PwC
November 29, 2026
Software Engineer
Phone Screen
Coding & Algorithms
Easy

0

0

0 solved


Given taxable income in cents and an ordered list of brackets (upper bound or none, and rate), return the tax owed, the effective rate and the marginal rate, using exact arithmetic so results never drift by a cent.

PwC's tax technology teams build calculation engines where a one-cent rounding error is a real defect, so a quick bracket problem in a phone screen probes correctness habits more than cleverness. The interviewer watches for the off-by-one at bracket boundaries and for money handled without floats.

What the Interviewer Expects
  • Apply each rate only to the slice of income inside its bracket
  • Handle the open-ended top bracket
  • Stop early once income is exhausted
  • Use integer cents and exact rates (Fraction or Decimal)
  • Define a single rounding rule and apply it once at the end
Key Topics to Cover
Progressive brackets
Exact arithmetic
Rounding rules
Boundary conditions
Tax engines
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 version brackets by tax year and jurisdiction?
  • How would you add a phase-out of a standard deduction above an income threshold?
  • How do you test boundary incomes systematically?
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

Brackets are sorted, e.g. 10% up to 10,000.00, 20% up to 40,000.00, 37% above. Income and bounds are integer cents; rates are exact fractions. Output tax in cents rounded half up once, plus effective ...

High-Level Design

Walk the brackets keeping the previous upper bound as lower. The taxable slice in a bracket is min(income, upper) - lower, if positive. Accumulate slice times rate exactly, then round once. Roundi...


Submit Your Answer
Markdown supported

Related Questions