Data Structures & AlgorithmsVery hardICPC regional · strings
Problem: Which approach finds the k-th lexicographically smallest substring of a string?
- A. Dijkstra on characters
- B. Suffix array with prefix counts over sorted suffixes
- C. Greedy by alphabetical order only
- D. Kadane's algorithm
Correct answer: B. Suffix array with prefix counts over sorted suffixes
Sorted suffixes and LCP values let you enumerate distinct substrings in lexicographic order.
More Coding Interview Problems questions
- Problem: What is the expected number of distinct values when n balls are thrown uniformly into n bins?
- Problem: Which algorithm is the standard way to find the minimum number of swaps to sort a permutation?
- Problem: What is the complexity of binary exponentiation for computing a^b mod m?
- Problem: What property of an array makes the two-pointer technique for pair sums valid?
- Problem: What is the purpose of a 'segment tree beats' structure?
- Problem: What is the number of comparisons needed in the worst case to check whether a sorted array of n elements contains a given value…