Subarray range with given sum | HashMap | GFG POTD | Dry Run & Explanation

preview_player
Показать описание
Guyz If you Like the Content

Plz Consider:
-Subscribing the Channel
-Like the video
-Comment your review

#hashmap
#array
#gfgpotd
#gfgalgorithms
#gfgpotdtoday
#Tree
#BST
#gfgpotd
#leetcodepotd
#algorithm
#graph
#datastructure
#topologicalsort
#directedgraph
#graphalgorithm
#sortalgorithm
#dfs
#kahnalgorithm
#programming
#coding
#competitiveprogramming
#codinginterview
#interviewprep
#graphtraversal
#cp
#dsa
#GraphAlgorithms
#GraphTheory
#Algorithms
#GFGPOTD (GeeksForGeeks Problem of the Day)
#LeetCodePOTD (LeetCode Problem of the Day)
#CompetitiveProgramming
#DataStructures
#SortingAlgorithms
#DFS (Depth First Search)
#KahnsAlgorithm
#CodingChallenge
#Programming
#InterviewPrep
#TechInterview
Рекомендации по теме
Комментарии
Автор

If You Like the Video then Plzz Consider Subscribing ☺.

CODE:
class Solution {
public:
int subArraySum(vector<int>& arr, int tar) {
int sum = 0;
int count = 0;

unordered_map<int, int> mp;

for(int i=0;i<arr.size();i++){
sum += arr[i];


if(sum == tar){
count++;
}
if(mp.find(sum-tar) != mp.end()){
count += mp[sum-tar];
}
mp[sum]++;
}
return count;
}
};

Veom
Автор

keep it up you will get 100 million subscribers one day

niha
join shbcf.ru