Data Structures & AlgorithmsHardGATE CS · ICPC regional

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

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

Correct answer: A. 3

The prefix aab equals the suffix aab, and no longer proper prefix matches a suffix, so the border has length 3.

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

Exams that ask this topic