Build a Prefix Sum Array
Precompute running totals once.
The Repeated-Sum Problem
Imagine answering hundreds of range-sum questions on one array. Summing each range from scratch is slow. A prefix sum fixes that. 🚀
What a Prefix Sum Is
A prefix sum array stores, at each index, the total of all elements up to that point. One precompute pass turns slow sums into instant answers.