The algorithm has two phases:
Process all updates on the difference array. Each update modifies exactly two positions.
Compute the prefix sum of the difference array to get the final result. This separates the update phase from the reconstruction phase. Total: . Time: . Space: .