Data Structures & AlgorithmsVery hardICPC regional · range queries

Problem: What is the best known approach for range-mode queries on a static array?

  1. A. Sorting the array once
  2. B. Square-root decomposition with precomputed block answers
  3. C. Bitwise AND of all values
  4. D. Dijkstra on indices

Correct answer: B. Square-root decomposition with precomputed block answers

Precomputing answers for block pairs and handling the leftovers gives O(sqrt n) per query.

More Coding Interview Problems questions

Exams that ask this topic