Difference array

medium

The exact inverse of a prefix sum. Two writes apply an increment to any range, however wide, and a single pass turns the differences back into values.

Best O(1) per updateWorst O(n + q)Space O(n)
Loading the difference array engine…

Where to go next