Skip to main content

Practice · 1 of 3

Subarray Sum Range

CHALLENGE
Difficulty: advanced+25 XP

**Problem.** Each query: n L R then n positive values. Print the number of subarrays with sum in [L, R]. **Constraints:** 1 ≤ n ≤ 200000; 1 ≤ a_i ≤ 1000; sums fit in long long. Prefix + two binary searches; O(n^2) W times out.

Back to lesson: Practice: Synthesis Gauntlet