Skip to content
SparkTime, home

Tagged #range queries

GuideTechnology

22 min read

Range Queries and Disjoint Set Union

What to do when prefix sums are not enough: Fenwick and segment trees for range queries with updates (optional depth), and disjoint set union with path compression and union by size for connectivity, cycles and Kruskal's algorithm (the part worth knowing).

GuideTechnology

19 min read

Prefix Sums and Difference Arrays

Answer range-sum queries in constant time with a running-total array, count subarrays with a given sum using a hash map, compute product-except-self, handle 2D regions, and apply many range updates at once with a difference array.