Data Structures & AlgorithmsVery hardICPC regional · strings

Problem: Which technique gives the number of distinct subarrays of an array of length n in O(n log n) time using a suffix structure?

  1. A. Plain hashing of every subarray in O(n^2)
  2. B. Kadane's algorithm
  3. C. Binary search on answers
  4. D. Suffix automaton or suffix array with LCP

Correct answer: D. Suffix automaton or suffix array with LCP

A suffix structure with LCP counts distinct substrings by summing n - sa[i] - lcp[i] over sorted suffixes.

More Coding Interview Problems questions

Exams that ask this topic