Mental Model
We keep track of sums of elements from the start and use a map to find if a previous sum can help form a subarray with sum k.
Analogy: Imagine walking along a path and counting steps. If you know how many steps you took before, you can quickly find if a segment of your walk adds up to a target number by subtracting previous counts.
Array: [1] -> [2] -> [3] -> [4] -> [5]
Prefix sums map: {0:1, 1:1, 3:1, 6:1, 10:1, 15:1}
ā current prefix sum
Keys are sums seen so far, values are counts of those sums