Subarray Sum Equals K

Prefix sums + hashing · Look up an earlier prefix · Stretch · about 25 min

Why it matters

This bridges precomputation and hash lookup in one reusable idea.

How it connects

Prefix sums answered fixed ranges. A map now finds earlier prefixes while you scan.

Try first

If current prefix is sum, which earlier prefix makes the gap equal k?

Interview cue

Prefix differences represent subarray sums, and the frequency map counts valid starts.