Prefix sums · 1 of 3
Prefix sum technique
Store every prefix sum once, answer any range sum with one subtraction, and count subarrays by their sum with a map of prefix sums.
Prefix sums · 1 of 3
Store every prefix sum once, answer any range sum with one subtraction, and count subarrays by their sum with a map of prefix sums.