当前位置:网站首页>2303. Calculate the total tax payable
2303. Calculate the total tax payable
2022-07-02 15:40:00 【Laver (nori)】
class Solution {
public:
double calculateTax(vector<vector<int>>& brackets, int income) {
double ans = 0;
for(int i = brackets.size() - 1; i > 0; --i){
auto &vec = brackets[i];
auto &vec1 = brackets[i - 1];
// When income Skip directly when not in this interval
if(vec[0] > income && vec1[0] > income){
continue;
}
// The difference in the middle
int diff = income - vec1[0];
// The tax that should be paid for this part of the difference , Here is the actual value 100 times
ans += (diff * vec[1]);
// The remaining uncomputed income
income = vec1[0];
}
// Calculate the minimum range , Tax payable , Here is the actual value 100 times
ans += (income * brackets[0][1]);
// Calculate the actual tax
ans /= 100;
return ans;
}
};边栏推荐
- MD5 encryption
- Leetcode skimming - remove duplicate letters 316 medium
- LeetCode刷题——两整数之和#371#Medium
- 【LeetCode】417-太平洋大西洋水流问题
- 03. Preliminary use of golang
- Leetcode question brushing - parity linked list 328 medium
- 10_ Redis_ geospatial_ command
- 【LeetCode】19-删除链表的倒数第N个结点
- Case introduction and problem analysis of microservice
- 【LeetCode】1254-统计封闭岛屿的数量
猜你喜欢

Thoroughly understand browser strong cache and negotiation cache
![[leetcode] 1162 map analysis](/img/9a/d04bde0417d4d5232950a4e260eb91.png)
[leetcode] 1162 map analysis

18_ Redis_ Redis master-slave replication & cluster building

Leetcode skimming -- sum of two integers 371 medium

自定义异常

SQL transaction

搭载TI AM62x处理器,飞凌FET6254-C核心板首发上市!

4. Jctree related knowledge learning

10_ Redis_ geospatial_ command

Semantic segmentation learning notes (1)
随机推荐
03. Preliminary use of golang
Yolov5 code reproduction and server operation
搭建自己的语义分割平台deeplabV3+
彻底弄懂浏览器强缓存和协商缓存
Steps for Navicat to create a new database
Infra11199 database system
基于RZ/G2L | OK-G2LD-C开发板存储读写速度与网络实测
[network security] network asset collection
【LeetCode】417-太平洋大西洋水流问题
【LeetCode】486-预测赢家
【LeetCode】1020-飞地的数量
LeetCode刷题——统计各位数字都不同的数字个数#357#Medium
[leetcode] 283 move zero
士官类学校名录
LeetCode刷题——奇偶链表#328#Medium
Folium, diagnosis and close contact trajectory above
【LeetCode】1140-石子游戏II
Thoroughly understand browser strong cache and negotiation cache
Cultural scores of summer college entrance examination
高考录取分数线爬虫