Data Structures & AlgorithmsHardCodeforces Div2 B-D · ICPC regional

For the string "aabaaab", what is the last value of the KMP prefix-function (the length of the longest proper prefix that is also a suffix of the whole string)?

  1. A. 3
  2. B. 2
  3. C. 1
  4. D. 0

Correct answer: A. 3

The prefix-function gives pi = [0, 1, 0, 1, 2, 2, 3]. The whole string's longest border is "aab" of length 3.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic