Concept Flow - Subarray Sum Equals K Using Hash Map
Start with sum=0 and map={0:1}
Iterate over array elements
Add current element to sum
Check if (sum-k) exists in map?
Yes→Add map[sum-k
Update count
Update map with current sum count
Repeat for next element
Return count
We keep track of cumulative sums and their counts in a map. For each element, we check if a previous sum exists that forms a subarray summing to k.
