Data Structures & AlgorithmsVery hardICPC regional · geometry
Problem: Which structure answers 'number of points in a rectangle' queries offline in O(log n) each using sorting and a Fenwick tree?
- A. A binary heap
- B. A trie
- C. A linked list
- D. Offline 2D counting with sweep and Fenwick tree
Correct answer: D. Offline 2D counting with sweep and Fenwick tree
Sweeping over x and querying a Fenwick tree over y gives rectangle counts from prefix differences.
More Coding Interview Problems questions
- Problem: What is the expected depth of a random binary search tree built from n distinct keys?
- Problem: What is the Hamming distance between 1011 and 1101 in binary?
- Problem: Which property must a graph have for Euler's theorem to guarantee an Euler circuit?
- Problem: What is the complexity of computing the number of distinct paths in a DAG with V vertices and E edges by DP?
- Problem: How many 4-digit numbers (from 1000 to 9999) are palindromes? Run the code. python print(sum(1 for x in range(1000, 10000) if…
- Problem: What is the time complexity of building a suffix tree of a string of length n over a fixed alphabet with Ukkonen's online…