当前位置:网站首页>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;
}
};
边栏推荐
- 居家办公让我绩效拿了C | 社区征文
- [proficient in high concurrency] deeply understand the basis of C language and C language under assembly
- Wechat official account server configuration
- N皇后问题
- WPF开发随笔收录-心电图曲线绘制
- 剑指 Offer II 025. 链表中的两数相加
- Structure de la mémoire JVM
- Kotlin
- Paper notes: lbcf: a large scale budget constrained causal forest algorithm
- 2022云的世界会更好吗
猜你喜欢

揭秘GES超大规模图计算引擎HyG:图切分

Protocol and hierarchy

MySQL 用 limit 为什么会影响性能?

旧手机变废为宝,充当服务器使用

这些老系统代码,是猪写的么?

Babbitt yuan universe daily recommendation: three players holding "tens of millions" of collections have revealed the "three routines" of the digital collection market

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

Mac PHP multi version management and swoole extension installation

ddia数据密集型应用系统设计 整理

内卷?泡沫?变革?十个问题直击“元宇宙”核心困惑丨《问Ta-王雷元宇宙时间》精华实录...
随机推荐
揭秘GES超大规模图计算引擎HyG:图切分
Apijson simple to use
mac php多版本管理以及安装swoole扩展
Redis Series - Overview day1 - 1
Difference between app test and web test
Notes: lbcf: a Large Scale budget Constrained causal Forest Algorithm
Kotlin
微信公众号服务器配置
论文笔记:LBCF: A Large-Scale Budget-Constrained Causal Forest Algorithm
剑指 Offer 39. 数组中出现次数超过一半的数字
n-queens problem
Wechat official account server configuration
Differences between et al and etc
How smart PLC constructs ALT instruction
JVM memory structure
TCP聊天+传输文件服务器服务器套接字v2.8 - 修复已知程序4个问题
Problems encountered in using MySQL
2022-06-17 网工进阶(九)IS-IS-原理、NSAP、NET、区域划分、网络类型、开销值
Structure de la mémoire JVM
好胖子带你学Flink系列-Flink源码剖析第一集Standalone启动脚本分析