Data Structures & AlgorithmsVery hardGATE CS · ICPC regional

What is the length of the longest proper prefix of abcab that is also a suffix of abcab (the border)?

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

Correct answer: D. 2

The border is ab, which is both the prefix and the suffix; the prefix function gives it directly. A proper prefix excludes the whole string.

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

Exams that ask this topic