Practice/Snowflake/Leetcode 2303. Calculate Amount Paid in Taxes
CodingMust
You are implementing a progressive tax calculator for a taxation system. In a progressive tax system, income is taxed across multiple brackets, where each bracket has an upper limit and a corresponding tax rate. Income is taxed sequentially through each bracket until either all income is taxed or all brackets are exhausted.
Given an array of tax brackets and a total income amount, calculate the total tax owed. Each bracket is represented as a pair [upper, percent], where:
upper is the maximum income that falls within this bracket (cumulative from zero)percent is the tax rate for this bracket (as a percentage, not decimal)The brackets are already sorted in ascending order by their upper bounds.
Example 1:
` Input: brackets = [[3, 50], [7, 10], [12, 25]], income = 10 Output: 2.65 Explanation:
Example 2:
` Input: brackets = [[5, 20], [10, 30]], income = 4 Output: 0.80 Explanation:
Example 3:
` Input: brackets = [[10, 10], [20, 20], [30, 30]], income = 30 Output: 6.00 Explanation: