Skip to main content

Practice · 1 of 3

Lucky Receipts

CHALLENGE
Difficulty: advanced+25 XP

**Problem.** Line 1: n S. Line 2: n integers (may be negative). Print the number of contiguous subarrays whose sum is exactly S. **Constraints:** 1 <= n <= 200000; |a[i]|, |S| <= 1e9. Two-pointer shrinking is the classic near-miss here.

Back to lesson: Practice: Mixed Drill — Final Synthesis