Data Structures & AlgorithmsHardGATE CS · TCS NQT

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

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

Correct answer: B. 2

The minimum insertions equal n minus the length of the longest palindromic subsequence. Here the longest is bcb (length 3).

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

Exams that ask this topic