int subarraySum(vector<int>& nums, int k) {
auto sum = 0;
auto cnt = 0;
unordered_map<int, int> m;
m[0] = 1;
for (auto i = 0; i < nums.size(); i++) {
sum += nums[i];
if (m.find(sum - k) != m.end())
cnt += m[sum - k];
m[sum]++;
}
return cnt;
}