当前位置:网站首页>Leetcode 560. And is the prefix and of the subarray of K
Leetcode 560. And is the prefix and of the subarray of K
2022-06-09 02:40:00 【Confident little screw】
Original link :Leetcode 560. And for K Subarray 
class Solution {
public:
int subarraySum(vector<int>& nums, int k) {
int n=nums.size(),res=0,tmp=0;
unordered_map<int,int> mp;
mp[0]=1;
for(int i=0;i<n;i++)
{
tmp+=nums[i];
if(mp.count(tmp-k)) res+=mp[tmp-k];
mp[tmp]++;
}
return res;
}
};
边栏推荐
- Dynamic programming / memo method n's K splitting n's maximum addend K splitting
- Discussion on MLIR Technology
- Sorting out the soft and hard decoding methods of ffmpeg
- Fight the high vision medical service of HKEx again, the gospel of short-sighted partners?
- The difference between new and newinstance() for creating objects
- How does the technical leader bring down a team?
- Rk3399 platform development series explanation (Introduction to kernel) 1.52. Call stack analysis of probe function in platform
- Greedy method / Huffman code
- The high-end is weak. Can Yanghe still keep the third place in the industry?
- Blue Bridge Cup_ Diophantine equation
猜你喜欢

Tiflash source code reading (III) design and implementation analysis of tiflash deltatree storage engine - Part 1

Golang of knowledge sharing -- a function based on whether a folder exists and whether a file exists

toggleRowSelection()失效的2个重要影响因素

The 600 yuan Tiktok cloud bouncing Di live studio project is the source code of the tuyere project that rewards the income from live broadcasting
![[network protocol] | [01] network byte order big end and small end](/img/9f/c69293aa8983161f4733a84389a311.png)
[network protocol] | [01] network byte order big end and small end

Using redis in business code to achieve caching effect

New textbook for self taught examination-p292

Reflection principle and application in C #

【HomeAssistant外网访问(cpolar)】

CVE-2020-3187
随机推荐
Basic method of missing data filling (1) -- k-nearest neighbors (KNN) filling
Greedy method / Huffman code
(10.3)【隐写缓解】隐写防护、隐写干扰、隐写检测
K splitting of dynamic programming /n maximum addend K splitting of n
CVE-2022-30525漏洞複現
(10.3) [steganography mitigation] steganography protection, steganography interference and steganography detection
Reflection principle and application in C #
数字电路加法器 基本原理(一)
Docker安装Redis
fatal error: juce_ core. h: No such file or directory
Blue Bridge Cup_ Diophantine equation
toggleRowSelection()失效的2个重要影响因素
贪心法/非01背包问题
贪心法/哈夫曼编码
Go技術日報(2022-06-07)——go程序員開發效率神器匯總
Sectigo certificate price
SQLite3 syntax (2)
toggleRowSelection()失效的2個重要影響因素
Jerry: if the user doesn't need to use all the keys, how should other keys be set? [chapter]
Exclusive application for consumer finance license by Weixin Jinke failed