PythiloMedium · 25 min · Task 50 of 100 · progress kept in this browser

Count target-sum subarrays

Return how many nonempty contiguous subarrays sum to target. Values may be negative or zero.

prefix, target = 5, 2
earlier_counts = {0: 1, 3: 2}
print(earlier_counts.get(prefix-target, 0))
Your task

Return how many nonempty contiguous subarrays sum to target. Values may be negative or zero.