Mental Model
We keep track of sums of elements from the start to each position and use a map to find if a previous sum allows a subarray to sum to k.
Analogy: Imagine walking along a path and counting steps. If you know the total steps at two points, subtracting them tells you how many steps you took between those points. The map remembers where you were before to quickly find these distances.
Array: [1, 2, 3, 4]
Prefix sums: 0 -> 1 -> 3 -> 6 -> 10
HashMap stores sums seen so far with their counts:
{0:1} initially
After first element: {0:1, 1:1}
After second: {0:1, 1:1, 3:1}
...