Data Structures & AlgorithmsVery hardICPC regional · range queries
Problem: What is the best known approach for range-mode queries on a static array?
- A. Sorting the array once
- B. Square-root decomposition with precomputed block answers
- C. Bitwise AND of all values
- 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
- Problem: Which concept describes the minimum number of comparisons to find the maximum of n numbers?
- Problem: What is the Ackermann-related complexity that appears in union-find analysis?
- Problem: What is the expected number of steps for a random walk on a path of length n starting at one end to reach the other end?
- Problem: Which algorithm computes a minimum-weight perfect matching in general (non-bipartite) graphs?
- Problem: Which property must a function satisfy for the Knuth optimisation of DP to apply?
- Problem: What is the maximum number of edges in a simple planar bipartite graph with V >= 3 vertices?