Data Structures & AlgorithmsHardGATE CS · Infosys

What is the length of the longest palindromic subsequence of the word character?

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

Correct answer: D. 5

The subsequence need not be contiguous; the DP recurrence takes the best of dropping either end when the ends differ. Confusing this with the longest palindromic substring gives a smaller value.

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

Exams that ask this topic