当前位置:网站首页>剑指 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;
}
};
边栏推荐
- 巴比特 | 元宇宙每日荐读:三位手握“价值千万”藏品的玩家,揭秘数字藏品市场“三大套路”...
- 【剑指 Offer II 091. 粉刷房子】
- Reading mysql45 lecture - index continued
- 千万级购物车系统缓存架构方案
- 论文笔记:Generalized Random Forests
- 2022-06-17 advanced network engineering (IX) is-is- principle, NSAP, net, area division, network type, and overhead value
- internship:Swagger下注解的涉及 接口的提供
- Day_ twelve
- Day_ 05
- 【機器學習】基於多元時間序列對高考預測分析案例
猜你喜欢

Reading mysql45 lecture - index continued

【機器學習】基於多元時間序列對高考預測分析案例

卡尔曼时间序列预测

六大专题全方位优化,阿里巴巴性能优化小册终开源,带你直抵性能极致

XXIX - orbslam2 real-time 3D reconstruction using realsensed435

Day_ seventeen

20省市公布元宇宙路线图

Optimization of lazyagg query rewriting in parsing data warehouse

3.条件概率与独立性

Bypass technology to talk about 'cross end'
随机推荐
Xinlou: un voyage de sept ans de Huawei Sports Health
Day_ thirteen
App测试和Web测试的区别
Tensorflow old version
1-8Vmware中的文件共享
计网 | 形象理解路由协议RIP、OSPF、BGP
Hash table, generic
内卷?泡沫?变革?十个问题直击“元宇宙”核心困惑丨《问Ta-王雷元宇宙时间》精华实录...
Uncover ges super large scale graph computing engine hyg: Graph Segmentation
[proficient in high concurrency] deeply understand the basis of C language and C language under assembly
论文笔记:Generalized Random Forests
How did I raise my salary to 20k in three years?
This latest research has revealed two secrets of cloudy development
Day_ twelve
Ncnn source code learning collection
Batch --07--- breakpoint lifting
代码注释的艺术,优秀代码真的不需要注释吗?
3.条件概率与独立性
Mysql database multi table query
Ad domain login authentication