Why it matters
Sqrt decomposition is simple + effective. Understanding enables competitive programming.
Advertisement
The architecture
Divide n elements into √n buckets.
Precompute per-bucket aggregate.
Query: partial + full buckets.
Advertisement
How it works end to end
Range sum: partial buckets at boundaries + full bucket sums.
Point update: update element + bucket aggregate.
Applications: many query types not just sum.