Glossary term

What is prefix sum? Meaning for developers

pre[i] = the sum of the first i items. Then any range sum is pre[r + 1] − pre[l], in O(1).

Learn it properly · DSALesson 20: Prefix SumPre-compute running totals so that any range sum is instant.

All DSA terms

Related terms

← All glossary terms, A to Z