Data Structures & AlgorithmsVery hardICPC regional · strings

Problem: Which approach finds the k-th lexicographically smallest substring of a string?

  1. A. Dijkstra on characters
  2. B. Suffix array with prefix counts over sorted suffixes
  3. C. Greedy by alphabetical order only
  4. 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

Exams that ask this topic