Concept Flow - Subarray Sum Equals K Using Hash Map
Start with sum=0, map={0:1}
Iterate over array elements
Add current element to sum
Check if (sum-k) in map?
Add map[sum-k
Add/update sum in map
Repeat for next element
End
Return total count of subarrays
We keep a running sum and use a map to count how many times each sum appears. For each element, we check if sum-k exists in the map to find subarrays summing to k.
