Data Structures & AlgorithmsVery hardCodeforces Div2 E · offline queries

Problem: Which result is the basis of Mo's algorithm's complexity analysis?

  1. A. Each query runs in O(1)
  2. B. All queries are sorted by value only
  3. C. Pointer movements over sorted blocks total O((n + q) sqrt n)
  4. D. Moves cost O(n^2) total

Correct answer: C. Pointer movements over sorted blocks total O((n + q) sqrt n)

Sorting queries by block makes the right pointer move monotonically inside each block, giving the sqrt bound.

More Coding Interview Problems questions

Exams that ask this topic