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?
- A. Plain hashing of every subarray in O(n^2)
- B. Kadane's algorithm
- C. Binary search on answers
- 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
- Problem: Which statement about the Knuth optimization for interval DP is correct when its monotonicity conditions hold?
- Problem: What is the time complexity of building a suffix array with prefix doubling and radix sort?
- Problem: Which problem is solved by the Aho-Corasick automaton?
- Problem: Which claim about the centroid decomposition of a tree is correct?
- Problem: What is the complexity of answering distance queries on a tree after O(n log n) preprocessing with the sparse-table LCA?
- Problem: In a Fenwick tree over n positions, what is the cost of a range-sum query combined with point updates?