Prefix Sum
Prefix Sum precomputes cumulative values so that range-sum queries can be answered efficiently. After O(n) preprocessing, the sum of a contiguous range can typically be calculated in O(1).
Preprocessing complexity: O(n).
Range query complexity: O(1).
Auxiliary space: O(n) for a separate prefix array.
Prefix sums are useful when many range queries are performed against mostly static data.
The technique can be extended to frequency counts and multidimensional grids.
0-2 years experience
2-5 years experience
5-8 years experience
8+ years experience