当前位置:网站首页>剑指 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;
}
};
边栏推荐
- Problems encountered in using MySQL
- Tensorflow old version
- Preliminary understanding of JVM
- XShell连接VMWare虚拟机
- Wireshark网卡无法找到或没有显示的问题
- 20省市公布元宇宙路线图
- Mysql database multi table query
- 3年,我是如何涨薪到20k?
- 【蓝桥杯集训100题】scratch指令移动 蓝桥杯scratch比赛专项预测编程题 集训模拟练习题第14题
- Navicat premium 15 for MAC (database development tool) Chinese version
猜你喜欢

Structure de la mémoire JVM

【 apprentissage automatique】 cas de prévision et d'analyse de l'examen d'entrée à l'Université basé sur des séries chronologiques multiples

A TDD example

Day_ 05

Day_ 18 hash table, generic

Wireshark network card cannot be found or does not display the problem

DDD概念复杂难懂,实际落地如何设计代码实现模型?

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

vscode插件自用

解析数仓lazyagg查询重写优化
随机推荐
[Jianzhi offer II 091. painting the house]
Optimization of lazyagg query rewriting in parsing data warehouse
JVM內存結構
解析数仓lazyagg查询重写优化
使用hbuilder X创建uniapp项目
千万级购物车系统缓存架构方案
Kettle表输入组件精度丢失的问题
使用PyWebIO测试,刚入门的测试员也能做出自己的测试工具
App测试和Web测试的区别
解析数仓lazyagg查询重写优化
揭秘GES超大规模图计算引擎HyG:图切分
加密潮流:时尚向元宇宙的进阶
Hash table, generic
Redis系列——概述day1-1
The art of code annotation. Does excellent code really need no annotation?
Effects and laws
Read mysql45 - a simple understanding of global locks and table locks
Reverse series to obtain any wechat applet code
Understanding of reflection part
论文笔记:LBCF: A Large-Scale Budget-Constrained Causal Forest Algorithm