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?

  1. A. A binary heap
  2. B. A trie
  3. C. A linked list
  4. 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

Exams that ask this topic