Please help
Unable to clr testcase 0
hi @goyalvivek
refer this -->
int subarraySum(vector<int>& nums, int k) {
unordered_map<int,int> mp;
int sum = 0;
mp[0] = 1;
int ans = 0;
for(int i=0;i<nums.size();i++){
sum += nums[i];
if(mp.find(sum - k) != mp.end()){
ans += mp[sum - k];
}
mp[sum]++;
}
return ans;
}
sir, I am not able to get this code, What is unordered_map<int,int> mp; ???
got it, but, my code is working just the same, but the testcase 0 in not cleared
Share ur code again… u have shared code of some other ques…
https://ide.codingblocks.com/s/655188 The link was correct, must have been some error on the backend
Done, Thanks for ur help
1 Like
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.