Arrays easy time O(n) space O(1)
Prefix Sum
Each position becomes the sum of everything up to and including it: a[i] += a[i-1]. Afterwards any range sum is a single subtraction.
Build running totals in place.
1 / 14
Practice
Machine twin: /dsa-viz-v2/prefix-sum.json — the full deterministic run as structured data.