Concepts3
∑MathIntermediate
Harmonic Lemma
The Harmonic Lemma says that the values of \lfloor n/i \rfloor only change about 2\sqrt{n} times, so you can iterate those value blocks in O(\sqrt{n}) instead of O(n).
#harmonic lemma#integer division trick#block decomposition+12
⚙️AlgorithmIntermediate
Mo's Algorithm
Mo's algorithm answers many range queries offline by reordering them to minimize pointer movement along the array.
#mo's algorithm#offline queries#range queries+12
🗂️Data StructureIntermediate
Sqrt Decomposition
Sqrt decomposition partitions an array into about \(\sqrt{n}\) blocks, each of size about \(\sqrt{n}\), to speed up range queries and updates.
#sqrt decomposition#block decomposition#bucket decomposition+11