当前位置:网站首页>剑指 Offer II 010. 和为 k 的子数组 前缀和差
剑指 Offer II 010. 和为 k 的子数组 前缀和差
2022-06-25 16:35:00 【Python ml】
class Solution {
public:
int subarraySum(vector<int>& nums, int k) {
unordered_map<int,int> mapp;
mapp[0]=1;
int pre=0,resCnt=0;
for(auto& x:nums){
pre+=x;
if(mapp.find(pre-k)!=mapp.end()){
resCnt+=mapp[pre-k];
}
mapp[pre]++;
}
return resCnt;
}
};
边栏推荐
- Bombard the headquarters. Don't let a UI framework destroy you
- App测试工具大全,收藏这篇就够了
- How to talk about salary correctly in software testing interview
- Batch --07--- breakpoint lifting
- Unity技术手册 - 生命周期旋转RotationOverLifetime-速度旋转RotationBySpeed-外力ExternalForces
- 论文笔记:LBCF: A Large-Scale Budget-Constrained Causal Forest Algorithm
- Read mysql45 the next day
- internship:Swagger下注解的涉及 接口的提供
- Do you know all the configurations of pychrm?
- Optimization of lazyagg query rewriting in parsing data warehouse
猜你喜欢
随机推荐
这项最新的调查研究,揭开多云发展的两大秘密
Read mysql45 the next day
[proficient in high concurrency] deeply understand the basis of C language and C language under assembly
App测试工具大全,收藏这篇就够了
Home office earned me C | community essay
Knowing these interview skills will help you avoid detours in your test job search
Record learning of hystrix knowledge --20210929
What processes are needed to build a wechat applet from scratch?
A TDD example
Uniapp to preview pictures (single / multiple)
APIJSON简单使用
[100 questions of Blue Bridge Cup intensive training] scratch command mobile Blue Bridge Cup scratch competition special prediction programming question intensive training simulation exercise question
App测试和Web测试的区别
WPF开发随笔收录-心电图曲线绘制
Hash table, generic
八种button的hover效果
[untitled]
论文笔记:LBCF: A Large-Scale Budget-Constrained Causal Forest Algorithm
知道这些面试技巧,让你的测试求职少走弯路
计网 | 形象理解路由协议RIP、OSPF、BGP