category-wise-problems

contains category wise problems(data structures, competitive) of popular platforms.

View the Project on GitHub mayankdutta/category-wise-problems

930. Binary Subarrays With Sum

method 1, fast

concept used

method 2

code ```cpp class Solution { public: int numSubarraysWithSum(vector& nums, int goal) { int n = nums.size(); map<int, int> mp; int sum = 0; int ans = 0; mp[0] = 1; for (int i = 0; i < n; i ++) { sum += nums[i]; ans += mp[sum - goal]; mp[sum] ++; } return ans; } }; ``` </details>