当前位置:网站首页>Sword finger offer II 010 Subarray prefix sum difference with sum K
Sword finger offer II 010 Subarray prefix sum difference with sum K
2022-06-25 17:04:00 【Python ml】
The finger of the sword Offer II 010. And for k Subarray
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;
}
};
边栏推荐
- Difference between app test and web test
- On Web 3.0
- Protocol and hierarchy
- Effects and laws
- mac php多版本管理以及安装swoole扩展
- 代码注释的艺术,优秀代码真的不需要注释吗?
- Ad domain login authentication
- How to view the change trend of cloud database from the behind of the launch of tidb to Alibaba cloud
- Internship: the annotation under swagger involves the provision of interfaces
- FreeRTOS内核时钟不对的问题解决
猜你喜欢

Singleton mode application

The art of code annotation. Does excellent code really need no annotation?

2022-06-17 网工进阶(十)IS-IS-通用报头、邻接关系的建立、IIH报文、DIS与伪节点

剑指 Offer 50. 第一个只出现一次的字符

Optimization of lazyagg query rewriting in parsing data warehouse

Pytorch official document learning record

论文笔记:LBCF: A Large-Scale Budget-Constrained Causal Forest Algorithm
![[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](/img/45/9955c9a5edeaa681f3fa8ce4041bfe.png)
[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

【黑苹果】联想拯救者Y70002019PG0

Do you know all the configurations of pychrm?
随机推荐
内卷?泡沫?变革?十个问题直击“元宇宙”核心困惑丨《问Ta-王雷元宇宙时间》精华实录...
Ten thousand volumes - list of Dali wa
try with resource
【精通高并发】深入理解C语言基础与汇编下的C语言
[proficient in high concurrency] deeply understand the basics of assembly language
剑指 Offer II 010. 和为 k 的子数组 前缀和差
深入浅出对话系统——自己实现Transformer
TCP聊天+传输文件服务器服务器套接字v2.8 - 修复已知程序4个问题
1-8Vmware中的文件共享
记一次基于PHP学生管理系统的开发
ES6知识点
【微服务|Sentinel】流控规则概述|针对来源|流控模式详解<直接 关联 链路>
Uniapp to preview pictures (single / multiple)
et al和etc区别
The art of code annotation. Does excellent code really need no annotation?
The role of the project manager in the project
PLSQL storage function SQL programming
Protocol and hierarchy
mood
Home office earned me C | community essay