Level: Unknown Level
Round: Full Journey · Type: Coding · Difficulty: 5/10 · Duration: 60 min · Interviewer: Neutral
Topics: Progressive Tax Calculation, Arrays
Location: San Francisco Bay Area
Interview date: 2026-01-14
Coding Question: calculate the total amount of tax paid given a 2D array of tax brackets and an income.
I was given a problem to calculate the amount paid in taxes based on a progressive tax system. I was provided with a 2D array called brackets, where each item is a pair [upper_bound, tax_rate]. The brackets list is sorted by upper_bound from smallest to largest. All upper bounds are distinct. I was also given an integer income and had to calculate the total tax.
The progressive tax works as follows:
Here's the problem description:
Problem Overview You are provided with a 0-indexed 2D integer array called brackets. Each item in this list is a pair [upper_bound, tax_rate]. This represents a tax bracket where:
upper_bound is the highest income amount included in this bracket. tax_rate is the percentage of tax charged for this bracket. The list brackets is sorted by upper_bound from smallest to largest. All upper bounds are distinct.
You are also given an integer income. You need to calculate the total tax based on a progressive tax system.
How Progressive Tax Works: Tax is calculated in steps or "chunks":
Money up to the first bracket's limit is taxed at the first rate. Any money above the first limit—but below the second limit—is taxed at the second rate. This pattern continues for each subsequent bracket until all your income is accounted for. Your goal is to return the total amount of tax paid.
` Sample Cases Case 1:
Input: brackets = [[3,50],[7,10],[12,25]], income = 10
Output: 2.65
Case 2:
Input: brackets = [[1,0],[4,25],[5,50]], income = 2
Output: 0.25
Input Limits 1 <= brackets.length <= 100 1 <= upper_bound <= 1000 0 <= tax_rate <= 100 0 <= income <= 1000 upper_bound increases strictly (the list is sorted and values are unique). `