Data Structures & AlgorithmsVery hardICPC regional · Amazon SDE OA

How many proper borders (non-empty prefixes that are also suffixes, excluding the whole string) does "abacabab" have?

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

Correct answer: C. 1

A border is a prefix equal to a suffix; the prefix-function chain enumerates all borders. Including the whole string as a border is the usual extra count.

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

Exams that ask this topic