Concepts5
⚙️AlgorithmIntermediate
2D Prefix Sum
A 2D prefix sum (also called an integral image) lets you compute the sum of any axis-aligned sub-rectangle in constant time after O(nm) preprocessing.
#2d prefix sum#summed-area table#integral image+12
⚙️AlgorithmIntermediate
Prefix Sum and Difference Array
Prefix sums precompute running totals so any range sum [l, r] can be answered in O(1) time as prefix[r] - prefix[l-1].
#prefix sum#difference array#imos method+12
⚙️AlgorithmIntermediate
Coordinate Compression
Coordinate compression replaces large, sparse, or arbitrary values with small consecutive integers while preserving relative order.
#coordinate compression#discretization#lower_bound+12
🗂️Data StructureIntermediate
Fenwick Tree - Range Update Range Query
A Fenwick Tree (Binary Indexed Tree) can support range additions and range sum queries by maintaining two trees, often called B1 and B2.
#fenwick tree#binary indexed tree#range add+12
🗂️Data StructureIntermediate
Fenwick Tree (Binary Indexed Tree)
A Fenwick Tree (Binary Indexed Tree) maintains prefix sums so you can update a single position and query a prefix in O(\log n) time with a tiny constant factor.
#fenwick tree#binary indexed tree#prefix sum+11