AlgoViz

Prefix sums

medium 20 min

Write the running totals of an array into P once, with P[0] = 0, and the sum of any range a[l..r] becomes one subtraction, P[r + 1] - P[l].