Subarrays summing to 3, negatives included
How many contiguous, non-empty subarrays of
[2, -1, 3, -2, 1, 2, -3, 4, -1, 2, 1, -2]
have sum exactly ?
Show hints (2)+
- A subarray sum is a difference of two prefix sums.
- Count, for each prefix, how many earlier prefixes are exactly 3 smaller - and seed the map with .
Answer
Reveal answer →Final answer
12
Create a free account to see the full worked solution and track your progress.
Interview format: Prop Trading, Systematic & Data-Driven Trading