Problems > Subarrays Summing to K > Editorial

Subarrays Summing to K — Solution & Editorial

Back to the Problem

Prefix-sum + hash map: while sweeping, add how many earlier prefixes equal (current prefix − K).

Complexity: O(N)