Back to DashboardUpgrade
Pro pattern
Upgrade to Pro to access this pattern and all 22 patterns.
PATTERN
Prefix Sums
Precompute cumulative sums to answer range sum queries in O(1) time, and combine with hash maps to count subarrays with a given sum in a single pass.
Learn Prefix SumsExplanation, templates & reference
Range Sum Query - Immutable
easy
Subarray Sum Equals K
medium
Product of Array Except Self
medium