Skip to main content

Prefix Sum

Allows O(1)O(1) range sum queries after O(n)O(n) preprocessing.

2D Prefix Sum

Sum of a rectangle from (x1,y1)(x1, y1) to (x2,y2)(x2, y2).

Difference Array

Used for range updates (add VV to [L,R][L, R]) in O(1)O(1). After all updates, calculate prefix sums to get the final values.

Practice

Sheet 7: Static Range Queries

Practice problems for this tutorial.