Subarray Range With Given Sum | GFG POTD | Hash Map | C++

preview_player
Показать описание
Hi guys,
Today I have solved gfg POTD, I have mentioned the code in comment box. Thanks for watching.

#coding​​ #helpajobseeker​​ #easyrecipes​​
#coding​​ #helpajobseeker​​ #easyrecipes​​ #leetcode​​ #leetcodequestionandanswers​​ #leetcodesolution​​ #leetcodedailychallenge​​ #leetcodequestions​​ #leetcodechallenge​​ #hindi​​ #india​​ #hindiexplanation​​ #hindiexplained​​ #easyexplaination​​ #interview​​ #interviewtips​​ #interviewpreparation​​ #interview_ds_algo​​ #hinglish​​ #github​​ #design​​ #data​​ #google​​ #video​​ #instagram​​ #facebook​​ #leetcode​​ #computerscience​​ #leetcodesolutions​​ #code​​ #learning​​ #dsalgo​​ #dsa​​ #coding​​ #programming​​ #100daysofcode​​ #developers​​ #techjobs​​ #datastructures​​ #algorithms​​ #webdevelopment​​ #softwareengineering​​ #computerscience​​ #pythoncoding​​ #codinglife​​ #coderlife​​ #javascript​​ #datascience​​ #leetcode​​ #leetcodesolutions​​ #leetcodedailychallenge​​ #codinginterview​​ #interviewprep​​ #technicalinterview​​ #interviewtips​​ #interviewquestions​​ #hinditech​​ #hindilearning​​ #helpajobseeker​​ #jobseekers​​ #jobsearchtips​​ #careergoals​​ #careerdevelopment​​ #jobhunt​​ #jobinterview​​ #github​​ #designthinking​​ #learningtogether​​ #growthmindset​​ #digitalcontent​​ #techcontent​​ #socialmediagrowth​​ #contentcreation​​ #instagramreels​​ #videomarketing​​ #gfg​​ #gfgstreek​​ #recursion​​ #cpp​​​ #motivation​ #motivation​ #developers​ #codingtools​ #gfg​ #potd​ #hashmap #bruteforce #teaching
Рекомендации по теме
Комментарии
Автор

int subArraySum(vector<int>& arr, int tar) {
int n = arr.size();

unordered_map<int, int> mp;
mp[0] = 1;

int count = 0, currSum = 0;

for(auto& num : arr){
currSum += num;

if(mp.count(currSum - tar)){
count += mp[currSum - tar];
}

mp[currSum] += 1;
}

return count;
}

galepraveen
Автор

Great explanation Sir...learnt a lot today, Thanks 👏 👍

Angopoonam