Data Structures & AlgorithmsHardGATE CS · TCS NQT

What is the length of the longest prefix of abacaba that is a palindrome?

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

Correct answer: A. 7

The whole string abacaba is a palindrome, so the longest palindromic prefix is the whole string of length 7.

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

Exams that ask this topic