Mental Model
We keep track of sums of elements from the start to each position and use a map to find if a subarray sums to k quickly.
Analogy: Imagine walking along a path and noting your total steps at each point. If you want to find a segment where you walked exactly k steps, you check if the difference between your current steps and some earlier steps equals k.
Array: [1, 2, 3, 4, 5] Prefix sums: [0, 1, 3, 6, 10, 15] HashMap stores sums seen so far with their counts. Example: sum 3 seen at index 2 -> map[3] = 1
