Data Structures & AlgorithmsHardGATE CS

What is the minimum number of characters that must be inserted anywhere in "CBAABDCABBDAC" to make it a palindrome?

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

Correct answer: B. 5

The answer is n − (length of the longest palindromic subsequence) = 13 − 8 = 5. The value 8 itself is the length of the palindromic subsequence, not the number of insertions.

More Coding Interview Problems questions

Exams that ask this topic