Problem 560 · Medium

Subarray Sum Equals K

Prefix sum with a hash map: count[prefixSum - k] gives the number of valid subarrays ending here.

Open the interactive visualisation