Count subarrays that sum to K
Given an array of integers (negatives allowed) and k, count the contiguous subarrays whose sum is exactly k. Keep running prefix sums and a map from each prefix sum to how often it has appeared.
No answer yet. Write the first one; the best answer gets endorsed.
