Data Structures & AlgorithmsVery hardGATE CS · TCS NQT

What is the minimum number of characters that must be inserted at the front of "abcdc" to make it a palindrome?

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

Correct answer: B. 2

Find the longest palindromic suffix; the characters before it must be mirrored in front. Checking only the whole string misses the shorter palindromic suffix.

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

Exams that ask this topic