Table of Contents 0:00 Problem Statement 0:29 Solution 7:51 Pseudo Code 9:36 Code - Python 10:18 Code - C++
@mathematics33985 күн бұрын
class Solution { public: // Function to count the number of subarrays which adds to the given sum. int subArraySum(vector& arr, int tar) { map mp; mp[0] = 1; int sum = 0, ans = 0; for (const auto i: arr) { sum += i; //cout
@mathematics33985 күн бұрын
class Solution: #Complete this fuction #Function to count the number of subarrays which adds to the given sum. def subArraySum(self,arr, tar): mp = dict() s = ans = 0 mp[0] = 1 for element in arr: s += element if s - tar in mp: ans += mp[s-tar] if s in mp: mp[s] += 1 else: mp[s] = 1 return ans
@mr.k44505 күн бұрын
Hey bud, if you dont mind can i get to know your LEETCODE and GFG handles, also want to know if you do CP and stuff?