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?
Yes No
Add map[sum-k
Update map with current sum count
Repeat for all elements
Return count of subarrays
We keep a running sum and use a map to count how many times each sum appears. For each new sum, we check if sum-k exists to find subarrays summing to k.